After installing apache in CentOS it would go to Apache 2 Test Page.

To locate this directory you need to go to /var/www/
In this directory you can create your file which you needs to run.

To set up Virtual Host navigate to /etc/httpd/conf/httpd.conf file

Open the file in gedit or editor of your preference.

Add the lines below

<VirtualHost *:80>
   DocumentRoot /var/www/sample/
   ServerName virtualhost1
</VirtualHost>

The document root points out to sample older in www directory

The server name is virtual host name you type in URL

You should also add the code in /etc/hosts file

127.0.0.1    virtualhost1

 

Once this is done dont forget to restart apache server in terminal by typing service httpd.restart

Now you are ready to go now.Open the browser and type http://virtualhost1/

Cheers!!!

Leave a reply