I am in the process of installing WordPress locally with Xampp and I will be creating several WordPress sites for clients. After these sites are completed I will upload them to a live server. Is there a way for me to have more than one WordPress installation in Xampp so I can keep these sites separate?
Create the new sites as virtual sites. Each new site resides in its own folder inside the /htdocs folder. You can host as many distinct websites as you want. To do this:
1) In your /xampp/apache/conf/httpd.conf file, uncomment the line (by removing the pound sign #) that says this:
That will include your vhosts file where we will set up the different sites when Apache starts.
2) In your /xampp/apache/conf/extra/httpd-vhosts.conf file (we just moved to another folder, the extra folder), create a setup similar to this:
And more possible sites if you desire. I'm not sure on the exact syntax, but that syntax above works fine for me. Any time you make configuration changes, you must restart Apache.
Where site1.com and site2.com are the domain names of the sites you are working on. Then in the /htdocs folder, you place the files for each respective site, site1, site2, etc., in the proper folder as specified in the DocumentRoot directive for each VirtualHost.
3) Then modify your hosts file so it will resolve requests to site1.com or the www version to the local server running on your machine instead of on the internet. This can be helpful for development as the URL received by Wordpress will contain the domain name and the correct URL as Wordpress expects. On Windows 7, the hosts file is located in C:\Windows\System32\drivers\etc. It may vary depending on your OS. Run Notepad as Administrator so you can edit the hosts file. Place a line similar to this in it for each virtual site you create and save the file:
127.0.0.1 site1.com www.site1.com
127.0.0.1 site2.com www.site2.com
All requests to site1.com will be directed to your localhost computer and if you have Apache running, Apache will serve the proper files based on what you put in vhosts. Modifying the hosts file, you will not be able to access the domain on the internet as all requests will be directed to your local server. When you want to access the domain name on the internet again, comment out the line in the hosts file like this:
#127.0.0.1 site1.com www.site1.com
All requests to site1.com will now be resolved using your ISP's DNS to the sites on the internet. When you want to access the version on your local server, remove the pound sign and save the hosts file.
It may be a good idea to create a backup copy of your hosts file before modifying it.
That was awesome! Thank you so much!
This topic is now closed. New replies are no longer allowed.