Setting up Virtual Host in LAMP on Elementary OS

Virtual Hosts are used to run multiple domain of a single IP address. This is especially useful to people who need to run several sites off of one virtual private server. The sites display different information to the visitors, depending on with which the users accessed the site.There is no limit to the number of virtual hosts that can be added to a VPS.

To setting up virtual host, It’s require the user to have root privileges. My assumption you are already install LAMP.

1. The first step in creating a virtual host is to a create a directory where we will keep the new website information. do create new folder and file on your site root directory, ex

create folder in root folder

2. go a head to etc folder and find hosts file and open it on your terminal, after that, adding a new line : and save that
Screenshot from 2014-03-21 09:55:47

Screenshot from 2014-03-21 10:02:20
3. still in etc folder, go a head to open apache2 folder and find sites-available, in this folder, create new documment empty and call it, and then open it in your favorite text editor (as root). copy it and save
Screenshot from 2014-03-21 10:12:33
4. go back to the terminal, and write this command : sudo a2ensite and then enter, put your password root
5. Reload your web server with this command : sudo /etc/init.d/apache2 reload or sudo apache2 reload
6. open up your favorite browser and go a head to typing this : and enter.. your virtual host is a live now.