Setting Up a Virtual Host on Ubuntu 14.04 for Local Environment

Linux, Ubuntu, 2015-06-17 00:12:07 UTC

1. Edit hosts, add this line localhost nitza-Lenovo-G405s coba

2. Create new file /etc/apache2/sites-available/coba.conf

<VirtualHost *:80>
 ServerName coba
 DocumentRoot /var/www/coba
 ErrorLog ${APACHE_LOG_DIR}/error.log
 CustomLog ${APACHE_LOG_DIR}/access.log combined
 <Directory "/var/www/coba">
  AllowOverride All
  Options FollowSymLinks MultiViews
  Order allow,deny
  Allow from all

3. Create a simple index.html file on /var/www/coba folder

4. Restart the server

$ sudo service apache2 restart

5. Go to http://coba

Now you can see a virtual host.