How to create Virtual Hosts PHP | Apache ?


Web Developer should have a requirement to work on various environment . Some projects are in plain php, some are in Framework like CodeIgniter, Symfony .. These all need different configuration and sometime need to use htaccess mode rewrite etc.

Those need to be in root folder.

We can access each  project like




simultaneously without altering any configurations each time we use. So different htaccess can run simultaneously with the hostname.

How can i add Virtual Host and Virtual Directory ?

  1. Search for “hosts” in your system folder

Creating Virtual Hosts

2. Edit this file using notepad

Add the following lines    localhost
::1                   localhost   wordzo.oi   accommodationcheap.oi   helloplot.oi

Description This is  the default ip address of local host

Ip address followed by domain name you want to use

you can add as domain name and when u type on your browser it will show your local site. It wont display actual google site .

For the development purpose i have added .oi extension. You can use your own extension.

3. open you httpd.conf located at apache folder with notepad or any other simple text editor

Append this code to your httpd.conf

#Virtual Host Directory Settings for wordzo

NameVirtualHost wordzo.oi:80

<VirtualHost wordzo.oi:80>
DocumentRoot E:/Project/iwordzo
ServerName wordzo.oi

# Other directives here


#Vitual Directory Settings for

NameVirtualHost accommodationcheap.oi:80

<VirtualHost accommodationcheap.oi:80>
DocumentRoot E:/Project/accommodationcheap
ServerName accommodationcheap.oi

# Other directives here


#Virtual Directory Settings for

NameVirtualHost helloplot.oi:80

<VirtualHost helloplot.oi:80>
DocumentRoot E:/Project/helloplot
ServerName helloplot.oi

# Other directives here


4. Restart your apache

5. That’s it 🙂

You can browse your localhost sites using




Note: These settings are for Windows machine

Reference Links


me : yeay its me arun

Tagged with: , , , , , , ,
One comment on “How to create Virtual Hosts PHP | Apache ?
  1. BINISH says:

    Its a good post, helped me to configure Apache in Solaris. Thanks Arun

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.