Virtual Hosts in Ubuntu. The easiest way to create new virtual host is to create a configuration file in /etc/apache2/sites-enabled. In this directory, you should see a symbolic link to the default virtual host located on /etc/apache2/sites-available/ if default host is enabled.
Usually, you want to do
cd /etc/apache2/sites-availablesudo vim virtualdomain.conf- Write or copy virtual host configuration (see example below)
sudo vim /etc/hosts- Point virtual domain to localhost. For example:
127.0.0.1 localhost virtualdomain sudo a2ensite virtualdomain.confsudo /etc/init.d/apache2 reload
a2ensite is a script that creates the symlink to /etc/apache2/sites-available/virtualdoain.conf in /etc/apache2/site-enabled directory. This allows to allows quickly disable or enable the virtual host without deleting or moving the configuration file.
Example of virtual host using IP and Port Note that if the server is not listen to port 81, you need to put Listen 81.
No comments:
Post a Comment