I use XAMPP for my local website development environment. It’s a wonderful free tool to use for this purpose, since I need access to a local WordPress distribution and the associated MySQL database to experiment with with themes and plugins.
One challenge I faced had to do with the fact that I use three different computers for development activities. Keeping data in sync across these platforms is important to me. The natural solution is to install Dropbox (referral link) on my various machines. (If you’re not familiar with Dropbox, be sure to read about maximizing free space before installing it.)
To be clear about what I set out to accomplish, I wanted to sync (A) my local web pages; and (B) the MySQL database across multiple machines. I did not want to sync the entire XAMPP distribution with all of its binaries. It is not difficult to make this work correctly, but it does require modifying a couple of configuration files.
Before we begin, I will assume you have XAMPP successfully installed and running on multiple machines independently (successfully running the HTTP server and MySQL database components). Our goal, then, is to make all of your installations access a single directory structure within Dropbox. A word of caution with all projects of this sort is that you should backup all of your data before making changes to your configuration files.
For my setup, the directory in which XAMPP is installed happens to be the same on all of my machines. Similarly, the directory in which my Dropbox folder is located is the same across all machines. This is not a requirement to make this work, but you may need to keep this in mind if your setup is different. My folder locations are:
XAMPP Installation = C:\xampp Dropbox Location = C:\Users\Patrick\Dropbox
Step 1 – Create web page directory in Dropbox folder. The first thing you need to do is set up a directory in your Dropbox folder to hold your web pages (HTML, PHP, etc.). For this example, I will create a folder named “C:\Users\Patrick\Dropbox\web-content”.
Step 2 – Change XAMPP configuration to point at this folder. There are two variables that need to be modified in the XAMPP configuration file. Edit “C:\xampp\apache\conf\httpd.conf” and modify DocumentRoot and Directory so they point to the new folder inside of Dropbox. For my setup, it looked like this:
OLD ENTRIES (search for them in "httpd.conf"): DocumentRoot "C:/xampp/htdocs" <Directory "C:/xampp/htdocs"> NEW ENTRIES (change lines above to this): DocumentRoot "C:/Users/Patrick/Dropbox/web-content" <Directory "C:/Users/Patrick/Dropbox/web-content">
Step 3 – Restart Apache and test. From the XAMPP control panel, stop and restart the Apache server. Create a file named “test.html” inside of your new Dropbox/web-content folder. Open “http://localhost/test.html” in your favorite browser, and you should see the contents of your test.html file.
Step 4 – Sync Dropbox across machines, and modify other configuration files. At this point, it should be easy to make your other computers access the same Dropbox folder. Go to your other machines and edit the “httpd.conf” file in the same was as you did on the first machine. If your Dropbox folder or XAMPP installations are located in different places than they were on your first computer, adjust directory names accordingly.
If you don’t need MySQL support for your development efforts, you can stop here. If you want to use something like WordPress, or another package that requires MySQL, continue with the rest of this process.
Step 5 – Turn off the MySQL server. Before moving things around, make sure the MySQL server is turned off from the XAMPP control panel.
Step 6 – Copy MySQL database into Dropbox. From your first machine, locate the directory containing the actual MySQL database. Copy that directory in its entirety to Dropbox. In my case, I simply had to copy the folder “C:\xampp\mysql\data” to “C:\Users\Patrick\Dropbox\web-database”.
Step 7 – Modify the MySQL configuration file. Edit the file “C:\xampp\mysql\bin\my.ini” and modify three variables to point at the new database folder inside of Dropbox.
OLD ENTRIES (search for them in "my.ini"): datadir="C:/xampp/mysql/data" innodb_data_home_dir = "C:/xampp/mysql/data" innodb_log_group_home_dir = "C:/xampp/mysql/data" NEW ENTRIES (change lines above to this): datadir="C:/Users/Patrick/Dropbox/web-database" innodb_data_home_dir = "C:/Users/Patrick/Dropbox/web-database" innodb_log_group_home_dir = "C:/Users/Patrick/Dropbox/web-database"
Step 8 – Restart the MySQL server and test. Restart the MySQL server and make sure everything is working as it was before.
Step 9 – Modify MYSQL configuration on other machines. Finally, make the same changes to the “my.ini” file on your other machines.
That should be it! A word of caution, though, is that these files should never be modified on more than one machine at a time. And more importantly, the MySQL server should only be running on one machine at a time. Conflicts from multiple active MySQL servers would likely wreak havoc.