Enable access without "www." on Ubuntu

Solution 1:

serverAlias needs to be title caps (ServerAlias) and you need to add whatever sites you want this virtual host to respond to on this line, separated by a space like so:

ServerAlias www.mydomain.gov.br mydomain.gov.br something.mydomain.gov.br

Make sure that you have a A host record for mydomain.gov.br (or a CNAME) so that it can be resolved properly. Also I'm not sure if you've ran a2ensite yet, you didn't say whether it was working at all or not.

EDIT Apparently you need step-by-step instructions on how to change your DNS records. However, unless you're going to post your actual domain (and we can look up your NS records), we have no idea who controls your DNS or how to change them.

To figure this out without posting your actual domain, you can do:

dig ns mydomain.gov.br

This should return some records like ns1.somecompany.com ns2.somecompany.com, etc.

Does "somecompany.com" ring a bell? If not, who registered this domain? Can you contact them? They likely have access to the nameservers or know someone who has access to the nameservers. You can also look up the WHOIS records and you may see an email address there that's familiar to you.

Solution 2:

This is definitely a DNS problem; you should of course configure your web server as appropriate for your needs, but if "mydomain.gov.br" doesn't point to it, you're not going anywhere :-)

Solution 3:

Your Apache config looks ok to me. The DNS record for mydomain.gov.br should point at the same IP address as the www. one, unless Apache is also listening on this IP address - but if it were then your site would probably work.

You need to check your DNS service to figure out where the record for the www. free record is being defined.