Difference between revisions of "Configuring virtual hosts in Ubuntu Apache"
From MyWiki
Line 12: | Line 12: | ||
</source> | </source> | ||
Create another one if necessary. <br> | Create another one if necessary. <br> | ||
+ | |||
+ | '''To enable the virtual hosts'''<br> | ||
+ | We can use the a2ensite tool to enable each of our sites like this:<br> | ||
+ | |||
+ | sudo a2ensite example.com.conf<br> | ||
+ | sudo a2ensite test.com.conf<br> | ||
+ | When you are finished, you need to restart Apache to make these changes take effect:<br> | ||
+ | |||
+ | sudo service apache2 restart |
Latest revision as of 11:58, 23 February 2016
Create a new virtual host file as follows:
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/example.com.conf
The edit it to look like below:
<VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www/html ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
Create another one if necessary.
To enable the virtual hosts
We can use the a2ensite tool to enable each of our sites like this:
sudo a2ensite example.com.conf
sudo a2ensite test.com.conf
When you are finished, you need to restart Apache to make these changes take effect:
sudo service apache2 restart