Wednesday, July 8, 2015

Create a virtual host in 8 easy steps

Objective: Create a virtual host for the domain

1. Create a directory in your document root

sudo mkdir -p /var/www/ 

2. Own the directory

sudo chown -R $USER:$USER /var/www/

3. Make the directory readable by the web server

sudo chmod -R 755 /var/www

4. Create the virtual host file from the Apache template

sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/

5. Edit the virtual host file

    DocumentRoot /var/www/
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

6. Enable the virtual host

sudo a2ensite

7. Don't forget to restart apache

sudo service apache2 restart

8. Edit your local host file (/etc/hosts)   localhost

No comments:

Post a Comment