Just setup an apache webserver in Debian 6 and add this following virtualhost:
<VirtualHost 123.45.67.89:80> ServerAdmin [email protected] ServerName mysite.com ServerAlias www.mysite.com DocumentRoot /srv/www/mysite.com/public_html ErrorLog /srv/www/mysite.com/logs/error.log CustomLog /srv/www/mysite.com/logs/access.log combined </VirtualHost> And the I enable it (the default vhost is also enabled):
a2ensite mysite.com Reload:
/etc/init.d/apache2 reload My /etc/hosts is as follow:
127.0.0.1 localhost.localdomain localhost 123.45.67.89 myhost.mysite.com myhost And then I tested by accessing mysite.com and www.mysite.com. Everything works fine at this point.
The problem is, every time I reboot, I can no longer access my site anymore. Doesn't work with mysite.com and www.mysite.com.
After fiddling around and monitoring the log, it seems that after reboot apache always look for files in /etc/apache2/htdocs. Which is not specified in any config files.
The only way I can make it work again after reboot is by issuing /etc/init.d/apache2 reload.
Any suggestions?
Thanks in advance.
[UPDATE 1]
This is the content of /etc/apache2/sites-enabled/
lrwxrwxrwx 1 root root 26 May 4 13:41 000-default -> ../sites-available/default lrwxrwxrwx 1 root root 29 May 4 11:12 mysite.com -> ../sites-available/mysite.com And this is the last line of the /var/log/apache2/error.log right after boot-up
[Wed May 04 13:43:17 2011] [notice] caught SIGTERM, shutting down [Wed May 04 13:43:37 2011] [notice] Apache/2.2.16 (Debian) configured -- resuming normal operations How can I make sure that apache is starting on boot? Issuing:
update-rc.d apache2 defaults Will output:
update-rc.d: using dependency based boot sequencing Should I try to put /etc/init.d/apache2 reload inside /etc/rc.local? (just to make sure it's executed)
[UPDATE 2]
I just did something that I think fixed the problem. What I did was change back:
NameVirtualHost 123.45.67.89:80 to
NameVirtualHost *:80 And then change every vhost files as well from:
<VirtualHost 123.45.67.89:80> to
<VirtualHost *:80> After that it just works. I tried to reboot 2-3 times and still works. I don't know if this is a good setting though.
The reason I use IP address in the first place is because the wiki/doc/library of my VPS provider said so.
So I guess I'll close the topic for now and do more testing.
Thanks guys.