While developing a website using apache or apache friends xampp, most of the developers would like to feel of working in local system with fully qualified domain name [www.google.com or anything].
Levelfive solutions also does the same thing when we are creating any solution for our customers. We feel like sharing this and it would help thousands of developer like us.
Let me explain with the scenario and how to achieve. Here it is.
- You have a local development folders in C:/xampp/htdocs/fork and C:/xampp/htdocs/pecc which you want to convert into fork.loc and pecc.loc
To achieve this, you need to change in three files
- hosts, http.conf, httpd.vhosts.conf
Let me give an explanation for each file and then i will show to modify the files.
This file is our local dns. Whenever we type anything on the browser, first it will try to check the resolution in this file. If it does not happen, it will look for dns registered with our internet provider.
The location of the file in Windows 7 is C:WindowsSystem32driversetc
You cannot modify the file easily. You have to give permission for this file for all the user.
Step 1: Right click the file hosts and click Properties
Step 2: From the popup, choose security tab
Step 3: Click Edit and Select Users
Step 4: Give all the permission to the users. Now, you will be able to modify the content of the files.
Apache server works based on this file. It has all the information including the port in which the apache has to run.
There is a little workout for apache to run on port 80. Here you can refer [ apache on port 80 ]
There is a entry in the http.conf for this file httpd.vhosts.conf. This file is responsible for converting the local website name map to the folder.
Now, lets start doing the scenario
Step 1: Open the hosts file in C:WindowsSystem32driversetc and add the entries and save it
Step 2: Open the file http.conf and search for “Virtual hosts” and uncomment the following line and save it
Step 3: Open the file httpd-vhosts.conf and add the entry for two local websites as below and save it
Step 4: Restart the apache server.
That’s it. It works !!!. Happy Programming.