Okay, today, I found a need for cloning my local Xampp web server. I simply wanted a second installation for testing certain applications separate from my main local development environment which has a lot of important material on it. So, how do I clone Xampp? I started by just trying to copy the entire directory, but when it told me it would take 14 minutes just to copy, a red flag went up. Then I realized, most of my files were in the htdocs directory because I have been putting websites there for development. Therefore, I decided to copy everything but htdocs and filezilla because I didn’t want filezilla, you can copy it if you need it yourself. Here is how I cloned Xampp on my local Windows 7 desktop.
- Make a new folder on your desktop or wherever your original Xampp installation is and name it something else other than what your original Xampp installation is called. I named my folder xampp2.
- Open your original Xampp installation folder and copy all of the files and directories except the “htdocs” directory. If you want to clone all of the websites in your xampp server also, then of course you should copy htdocs as well, but some of the websites may not function properly on the cloned server if they were configured to run with the original installation of Xampp.
- When your files are finished copying to the xampp2 folder, open it and make a new htdocs directory if you didn’t copy the old one over.
- Make a test index.php file with a simple php script to test your cloned server with something like <?php echo “if you see this, PHP works on your server…”; ?> in it.
- Open up the file xampp2/properties.ini in a text editor such as notepad or notepad++ for editing and do a case sensitive search and replace for xampp and replace every instance with xampp2 or whatever you named your clone’s main folder.
- Open apache/httpd.conf and replace all occurrences of xampp with xampp2(or whatever you named your cloned xampp directory) except for the one in the line that reads: Include “conf/extra/httpd-xampp.conf”, leave that one alone.
- Open up apache/extra/httpd-xampp.conf and change all but a couple instances of xampp with xampp2. Leave the secone xampp in the line” <Directory “C:/Users/ian/Desktop/xampp2/htdocs/xampp”>” alone and leave th one that has “xamppsecurity” in it alone and also the one that has a pipe after it like: “xampp |”, but change the rest to xampp2.
- Then open apache/extra/httpd-vhosts.conf and change the two xampp occurrences with xampp2 and save the file.
- Open apache/extra/httpd-autoindex.conf and replace both times you see xampp with xampp2 and save.
- Also, open apache/extra/httpd-dav.conf and replace all occurrences of lowercase xampp with xampp2.
- To be safe, also replace xampp with xampp2 in apache/extra/httpd-ssl.conf. If you are using HTTPS or SSL support for anything, then there is a little more you need to do which is beyond the scope of this tutorial, but suffice it to say that you will be replacing a lot more xampp occurrences because you will need to go in the ssl directories and do the same thing there. Most of you will not be using SSL especially on a local test or development server and if you are, you can probably figure out the changes on your own just from what you have read so far anyway.
- Now this step I had to learn the HARD WAY, so this will save you a huge headache if you do it now instead of after it is too late like I did the first time doing a clone of Xampp. You have to change all the occurrences of xampp with xampp2 inside the my.ini file located inside the xampp2/mysql/bin directory. Open xampp2mysql/bin/my.ini in notepad and search and replace lower case xampp with lower case xampp2 or you will have major issues. If you read this to late, and mess up the database on your original Xampp server, remember, you made a copy, so you may have a way out. Go get your copy in xampp2 before you mess it up and replace the entire data directory with the copy if you have to only.
- Now once you are sure both Xampp servers have their databases set up properly you can move on. Make sure by going into each, starting it and checking PHPMyAdmin to be sure. Then you can go into your xampp2/mysql folder and make a backup of the entire data directory just to be safe as it is always good to do when working with database tables. Copying the xampp2/mysql/data directory, will give you a backup of all your original Xampp tables before you go and mess anything up by accident or by misconfiguration as I did once(and it was a nite mare!). After you make a backup of the data directory, you can go into the xampp2/mysql/data folder and delete all your tables from the original xampp install except the following ones: mysql, performance_schema, test, webauth and phpmyadmin. Those tables you should keep, the rest you can delete as long as you are not cloning all of the website in your Xampp server also.
- Navigate to the file xampp2/xampp-control.exe and start the Xampp control panel.
- Click on the start buttons for both Apache and Mysql in the Xampp control panel to fire up your cloned server. You will probably have to click a couple pop ups to allow the services through your firewall the first time you start each service.
- Once both Apache and Mysql are running, open your favorite web browser and type “localhost/” and see if it takes you to your test index.php page you created above in step 4. You should see the test text from your .php script if everything is working. If you have issues read below for troubleshooting. Remember, you should see just “This is output by PHP, so if you are seeing this, PHP is working on your server…” if you made your test php script as I suggested above.
Here are a few possible problems and fixes if you are having issues:
- If your page didn’t resolve at all, you may have tried to install your clone in the wrong directory. This tutorial assumes that you are installing your clone in the same directory that your original Xampp installation is in under a new name, so for example, if your original Xampp directory is yourname/Desktop/xampp, then your clone should be in yourname/Desktop/xampp2 or it is likely not to work.
- If you go to localhost in your browser and get the Xampp slash page instead of your test script, then you missed one of the replacement xampp2 cases, so search through all the files and make sure you changed all the xampp directories to xampp2 and try again.
- My xampp2 install won’t open because of a blocked port! If this happens, sometimes Skype is the culprit. If you have skype open, close it and try to open Xampp again. If it works that was the problem and you can then start Skype after and Skype will open on a different port. If that wasn’t the problem then you may have your original xampp install running at the same time, shut it down and try to open the clone again and it should work. Unfortunately you cannot run both at the same time.