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!!!

Install Apache Server in Terminal CentOS

 yum install httpd

Check Status of Apache Server

/etc/init.d/httpd status

Start Apache Server

/etc/init.d/httpd start

Start MySQL Terminal

/etc/init.d/service mysqld start

Check Status of MySQL

/etc/init.d/service mysqld status