Name-based virtual hosting enables us to serve different domains from a single server. All we need is to add this line to /etc/apache2/sites-available/default:
NameVirtualHost *
The * specifies that Apache will serve requests for all IP addresses; optionally we can specify only a certain IP on the server.
Next, we create a new for each different domain we want to serve.
This can be done either by adding a few lines inside /etc/apache2/sites-available/default
<VirtualHost *>
ServerName www.lxf.gr
ServerAlias lxf.org
DocumentRoot /media/oxy/www/lxf
</VirtualHost>
or by creating a new file (i.e. lxf.gr) inside /etc/apache2/sites-available
<VirtualHost *>
ServerAdmin [email protected]
ServerName lxf.gr
ServerAlias lxf.gr
DocumentRoot /media/oxy/www/lxf
<Directory /media/oxy/www/lxf>
Options Indexes FollowSymLinks
Options -MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
CustomLog /var/log/apache2/lxf-access.log combined
ServerSignature On
</VirtualHost>
and symlinking it to /etc/apache2/sites-enabled:
sudo ln -s /etc/apache2/sites-available/lxf /etc/apache2/sites-enabled/
Technorati Tags: apache, linux