Apache 2.0 Default Virtualhost That Works

By | April 28, 2008

If your server does not have any kind of graphic interface (Directadmin, Cpanel, etc…), you’ll have to create Apache Virtualhosts manually. You will need a working Virtualhost template for this. Using Apache example will guide you to problems with .htaccess files, therefore it will work too. I will show you a working example for Apache 2. Here it is:

<VirtualHost localhost.com:80>

ServerName www.localhost.com
ServerAlias www.localhost.com localhost.com
ServerAdmin webmaster@localhost.com
DocumentRoot /var/www/html/localhost.com/
UseCanonicalName OFF

<Directory /var/www/html/localhost.com>

Options +Includes -Indexes
Allowoverride All



In this sample your user files are located at /var/www/html/localhost.com. It will also deny directory listing (make sure to take a look at DirectoryIndex directive and add all the necessary index types in httpd.conf). Have fun as everything you need is to change localhost.com to your domain name.