Feb
10th

Domain.com Is Fine But WWW.Domain.com Doesn’t Work!

Filed under The Server Room | Posted by Gary

This issue didn’t start out being a web problem. A client who was running MySQL 4.0.x needed an upgrade done to MySQL 4.1.x because of a new script they had bought. So, I trawled google for some info on the easiest way to do they upgrade (it was on a WHM-based server). That’s my first tip … it doesn’t matter how many years you have been administering/building/breaking servers … there will nearly always be someone who knows how to do the same job better, faster or cleaner. So, I rarely do anything without first searching around a little.

I found a nice, easy guide to doing this upgrade at WebHostGear and set about getting the job done. It all went to plan and after around 20 minutes the MySQL database had been upgraded. I checked a couple of sites by going directly to their domains (i.e. domain.com rather than www.domain.com) and it looked like all was well.

Some hours later, the client contacted me to tell me that one of the sites was down. I checked it using the address they gave me and sure enough, we were getting the default Apache ‘success’ page instead of the site. That told me straight away that for some reason, Apache wasn’t configured for the domain that I was trying to get to. So, first off I checked that CPanel and DNS were still okay (which they were) and then I did another search. At some point I saw a message from someone saying they had run  EasyApache  to rebuild their web server and since doing it they couldn’t get to any ‘www’ domains but could get to the domain itself.

A light immediately went on 🙂 and I checked a few of my clients domain and sure enough … same problem. It turns out that the EasyApache installer had set most of the ServerAlias config lines to the domain without the ‘www’. The fix is quite easy:

Edit /etc/httpd/conf/httpd.conf and check the ServerAlias for each virtual host. They should be set to www.domain.com rather than domain.com. After doing that, you need to run a command to update WHM’s config otherwise WHM will overwrite your changes. The command to make your changes ‘stick’ is:

/usr/local/cpanel/bin/userdata_update –update

After running that command, just restart your web server (service httpd restart) and it should all be good again.

You must be logged in to post a comment.