Wednesday, May 7, 2014

Copy First Virtual Host and Customize for Second Domain of Apache/2.4.7

 Step 1 :
Start by copying the file for the first domain:
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/example.com.conf
Step 2 :
Open the new file in your editor with root privileges:


sudo nano /etc/apache2/sites-available/example.com.conf

 Step 4 :
The file will look something like this (I've removed the comments here to make the file more approachable):

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Step 5 :
We can use the a2ensite tool to enable each of our sites like this:
sudo a2ensite example.com.conf 
Step : 6

When you are finished, you need to restart Apache to make these changes take affect:
sudo service apache2 restart 
Step 7 :

Open browser  enter  example.com

Done! Good Luck ^-^

No comments:

Post a Comment