Web Info and IT Lessons Blog...

Monday 6 April 2015

How to make a virtual host using xampp in php?


The previous lesson of PHP Lessons series was about dynamically including files in PHP and in this lesson we will to create a virtual host using xampp server in PHP.

Virtual Host Using Xampp in PHP

Normally if you want to access your php test project on localhost you would type localhost/test in your browser to check the output of your php code. What if you want to access your test project by typing www.test.com in your browser. For this purpose you will need to create a virtual host for your test project.

To make a test virtual host in xampp navigate the following path:


C:\xampp\apache\conf\extra

and open httpd-vhosts.conf file. Add the following lines to the file and save it


<VirtualHost *:80>
    DocumentRoot "C:\xampp\htdocs\test"
    ServerName www.test.com
    ServerAlias www.test.com
</VirtualHost>

Now open the following folder


C:\Windows\System32\drivers\etc

and open the host file using notepad with administrative rights. At the end of the file add this line


127.0.0.1    www.test.com

and save it. Restart your Apache service for the changes to get effective and now access your local test project through (www.test.com). You can create virtual hosts for all of your projects using the same method and access your projects via test urls.

For more lessons about PHP subscribe on InformationBitz.com

No comments:

Post a Comment