Just setup an apache webserver in Debian 6 and add this following virtualhost:
<VirtualHost 220.127.116.11:80> ServerAdmin firstname.lastname@example.org 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):
My /etc/hosts is as follow:
127.0.0.1 localhost.localdomain localhost 18.104.22.168 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.
Thanks in advance.
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
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)
I just did something that I think fixed the problem. What I did was change back:
And then change every vhost files as well from:
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.