Sunday, September 21, 2014

Create Virtual Host Apache Ubuntu

Virtual host make a server can handle many domain on it. To make virtual host on apache, follow steps below. This tutorial needs prerequisite an apache installed.

  1. Create directory structure. You can make like this
  2. mkdir -p /var/www/example.com/public_html
  3. Grant permission to user that become administrator of that web
  4. chown -R $USER:$USER /var/www/example.com/public_html chmod -R 755 /var/www
  5. Create virtual host file
  6.  nano /etc/apache2/sites-available/example.com.conf
  7. Fill example.com.conf with text below 
  8. <VirtualHost *:80> ServerAdmin admin@example.com ServerName example.com ServerAlias www.example.com DocumentRoot /var/www/example.com/public_html ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
  9. Enable the new virtual host file
  10. a2ensite example.com.conf
  11. Restart Apache
  12. service apache2 restart
For another virtual host, you can repeat steps above with a change in example.com with your domain.

For further reading, visit:

0 comments:

Post a Comment