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

127.0.0.1 localhost
127.0.1.1 nitza-Lenovo-G405s
127.0.0.1 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
 </Directory>
</VirtualHost>



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.


Share: