Tag Archives: linux

Apache2, Simply create vhosts

www.rabbit.com is the new vhost that we are trying to create, first we have to copy the default vhost configuration :

sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/www.rabbit.com

It’s important to know that apache2 loads configurations from /etc/apache2/sites-enabled/ so we have to add a link of our vhost configuration on this directory, then we have to change the configurationĀ  :

<VirtualHost *:80>
        ServerAdmin admin@rabbit.com
        ServerName www.rabbit.com
        DocumentRoot /home/www.rabbit.com
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /home/www.rabbit.com>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog /var/log/apache2/rabbitcom.error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog /var/log/apache2/rabbitcom.access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>

It’s important to add the directive :


ServerName www.rabbit.com

And to change the location of your directory.

For the activation of the vhost we can use :

sudo a2ensite www.rabbit.com

Or create a link :

ln -s /etc/apache2/sites-available/www.rabbit.com /etc/apache2/sites-enabled/www.rabbit.com