PDA

View Full Version : [ubuntu] Changing hostname broke apache


nimbostratus
July 23rd, 2009, 10:40 AM
Hi

I tried changing the hostname on my machine by changing /etc/hostname and restarting. Apache stopped working so I changed the hostname back and restarted again. Apache still doesn't work.

My hostname file is now:

aaron-desktop

My hosts file contains:

127.0.0.1 aaron-desktop localhost.localdomain localhost
127.0.1.1 aaron-desktop

And the relevant part of my apache conf contains (it's a development machine I only want to access locally):

Order deny,allow
Deny from all
Allow from localhost

Accessing that directory from my machine gives a HTTP 403 Forbidden error.

The weird thing is that if I change 'localhost' to 'aaron-desktop' in the apache conf, everything works fine.

I guess that means apache isn't connecting the IP of the request (127.0.0.1 - I've checked that) to the name 'localhost'.

Can anyone tell me why not?

Thanks
Aaron

wojox
July 23rd, 2009, 10:49 AM
Change hosts file to:

127.0.0.1 localhost
127.0.1.1 aaron-desktop

nimbostratus
July 23rd, 2009, 11:47 AM
Great, thanks.

I tried a few other combinations too - it seems anything with localhost first on the line works.

I went back to changing the hostname as I wanted to originally - after restarting, the hosts file was broken again. Fixed it no problem, but it seems weird that the automatic updating of hosts breaks it. Maybe a bug?