Creating A Local Domain Using Apache Virtual Hosts

From Joseph Luis Wiki
Jump to: navigation, search

Taken from here

The basic Virtual Host configuration we're seeking is as follows:

# Setup Listening Port
NameVirtualHost *:80

# Ensure "localhost" is preserved unchanged pointed
# to the default document root for our system.
<VirtualHost *:80>
    ServerName localhost
    DocumentRoot /var/www
</VirtualHost>

# Setup "helloworld.tld" Virtual Host
<VirtualHost *:80>
    ServerName helloworld.tld
    DocumentRoot /home/padraic/www/helloworld/public

    <Directory /home/padraic/www/helloworld/public>
        Options Indexes FollowSymLinks Includes
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

and add to /etc/hosts (for this example)

127.0.0.1 helloworld.tld