Categories
Other

Webmin Virtual Host Not Working? Here’s How To Fix It.

One of the most frustrating experiences when setting up a new web server is trying to get your virtual hosts to work correctly.  The program Webmin is supposed to make this easier, however you’re are often left by Webmin with a virtual host (or hosts) that is not working.  There are a few tell-tale signs that your virtual host files are broken or not working correctly, and the most obvious is that you go to one site, but get another.  For instance, lets say that you have a virtual host set up for apacheWebSite.com and it points to /home/apacheWebSite.com/htdocs.  Now let’s assume you have another virtual host setup for nginxWebSite.com and it points to /home/nginxWebSite.com/htdocs.  Webmin has configured your virtual host wrong if you go to apacheWebSite.com and get nginxWebSite.com’s content (or vice-versa).  To fix it, do the following:

1:  Open /etc/apache2/apache2.conf in the editor of your choice.

2:  Comment out (using ‘#’) or delete the line that says:

# Include the virtual host configurations:
Include /etc/apache2/sites-enabled/

3:  Add the following to the bottom of the same file (substituting your site information) and then follow it as a template for adding more virtual hosts in the future.

#Virtualhosts
<VirtualHost *:80>
DocumentRoot /var/www
</VirtualHost>

<VirtualHost *:80>
DocumentRoot “/home/wrestlingaddix.com/htdocs”
ServerName wrestlingaddix.com
ServerAlias www.wrestlingaddix.com
<Directory “/home/wrestlingaddix.com/htdocs”>
allow from all
Options +Indexes
</Directory>
</VirtualHost>

<VirtualHost *:80>
DocumentRoot “/home/dansbikeshop.org/htdocs/dansbikesWP”
ServerName dansbikeshop.org
ServerAlias www.dansbikeshop.org
<Directory “/home/dansbikeshop.org/htdocs/dansbikesWP”>
allow from all
Options +Indexes
</Directory>
</VirtualHost>

4:  Reload Apache by executing /etc/init.d/apache2 reload.

That’s it!  It’s really much simpler to create the virtual hosts without Webmin.