Earlier, we saw the procedure to setup local server environment with XAMPP in Windows and MAMP in Mac. Being a web developer, it is essential to test the web pages & applications on multiple browsers across multiple operating systems, just to make sure of the compatibility. Now, let us see how to work anywhere on the go.
Choosing your syncing solution
| Solution | Advantages | Disadvantages |
| Using Dropbox or Syncplicity |
|
|
| USB Flash Drive |
|
|
| USB drive + dropbox |
|
|
Option 1 : Syncing XAMPP and MAMP using Dropbox
We can use online files sharing and syncing services such as dropbox. The basic version has a limit of 2 GB, but is usually sufficient for this purpose.
Update: I stumbled across Syncplicity. It has a basic version with same 2GB limit like dropbox. Unlike current version of Dropbox, syncplicity comes with selective syncing. Choosing either service, your choice.
Before we start, please note
-
In this guide, please name the Hard links exactly as the folder they points to. No custom names please.
-
Hard links are same as Junction points. They provide better functional links for directory access than Symbolic Links(SymLinks).
-
Servers mean the “Apache” and “MySQL” servers. And XAMPP is a server Environment.
-
In the guide, “Move” refers to “Cut and paste”. Not copy and paste.
-
If you use only use windows machines, You can try to sync MySQL dbs.
The basic idea
-
We move the htdocs folder (located in XAMPP root folder) inside the dropbox folder.
-
Then we create a hard link named exactly “htdocs”, which points to the “htdocs” folder inside the dropbox.
-
xampp server takes the htdocs hard link for a real folder, while MAMP allows us to have the htdocs anywhere on the disk.
Before you start, setup Dropbox and make sure it is working.
Syncing XAMPP with dropbox
Dropbox by default will sync only the files inside the “Dropbox” folder. It does not sync the outside folders. An easy workaround is by moving the “htdocs” folder inside the dropbox folder and create a junction point(hard link) in the xampp folder. Both windows and Mac OS X have inbuilt utilities for creating hard links.
Windows 7
Windows 7 comes with a command line utility named “mklink” which we will be using. There is another utility named “junction.exe” from Microsoft Sysinternals, which does the exact same thing. well, the choice is yours. If you prefer to use the utility “junction.exe”, copy it to the “windows” folder.
mklink.exe and junction.exe Syntax
Type “mklink” in the command prompt and press enter to see the information. Similarly, for junction.exe.
As you can see above, mklink with the parameter “/J”, creates a directory junction, which is exactly what we need. The Junction utility does not need parameters.
Make sure the servers are not running. Backup the entire XAMPP folder before proceeding.
Syntax
mklink.exe /J "X:\Path\to\hardlink" "Y:\folder\link\points\to" junction.exe "X:\Path\to\hardlink" "Y:\folder\link\points\to"
and an example.
mklink /J "D:\xampp\htdocs" C:\Users\username\Documents\My Dropbox\htdocs" junction.exe "D:\xampp\htdocs" C:\Users\username\Documents\My Dropbox\htdocs"
Procedure
-
Locate the xampp folder.
-
Stop the xampp server. Use the “xampp-stop.exe” in the xampp root folder to do so.
-
Open the command prompt. (Press keys
+ R –> type “cmd.exe” and press enter”) -
we move the “htdocs” folder inside the dropbox folder.
-
-
-
Say, we have the xampp installation in the path “D:\xampp” with “htdocs” folder inside it.
-
we move it into the dropbox (located in “C:\Users\username\Documents\My Dropbox\htdocs\”)
-
Following command does that.
-
-
-
mklink /J "D:\xampp\htdocs" C:\Users\username\Documents\My Dropbox\htdocs" junction.exe "D:\xampp\htdocs" C:\Users\username\Documents\My Dropbox\htdocs"
Now a junction point is created. And the dropbox starts syncing the files with the online dropbox server. (dropbox tray icon turns from syncing icon
to the All done icon
). Now repeat the process on other computers.
Syncing MySQL databases? Not a good idea really. Yet, it might work at some situations. Scroll to the end of this article to read more on syncing MySQL dbs.
Syncing MAMP with Dropbox
-
No need to fiddle with hard links, because MAMP allows us to have our “Document Root” (htdocs) anywhere on the disk. Cool!
-
Open the MAMP application and Click “Preferences”.
-
Change the Document Root to the path of the htdocs in the dropbox folder. Click OK.
-
Stop and Restart the servers.
Syncing the Linux XAMPP
Both dropbox client and XAMPP are available for linux. Setting up XAMPP in linux needs another full blown article.
Linux comes with the terminal utility “ln”, which we will use. Dropbox is located in your User directory( ~ ) . XAMPP folder is in /opt/lampp. Create links to htdocs folder with command “ln –s”.
The whole process may seem a little bit over complicated and scary. But if you have installed XAMPP in linux and reading this, Then you can do it. If time permits, I will update the blog with another article on Complete local server configuration.
Okay, what about MySQL databases?
MySQL databases needs replication rather than synchronization. Setting up MySQL replication is kinda tough and beyond the scope of this article. Yet, syncing may work, provided
-
-
All the Server pcs are running windows.
-
No more than a single server run simultaneously.
-
Steps are similar to syncing the htdocs [-recall-]. Locate the “mysql” found in the root of xampp folder.
-
Backup your entire XAMPP directory. Seriously.
-
Make sure the servers are stopped. If not, stop the servers using “xampp-stop.exe”.
-
Move the “mysql” folder to your dropbox folder.
-
Setup a junction point aka hardlink to “mysql” folder(now in dropbox) to the XAMPP folder. Using mklink.exe, a typical example would be
# mklink.exe syntax mklink.exe /J "Y:\path\to_the\LINK" "X:\Path_of\folder\within\dropbox" # Example mklink /J "D:\xampp\mysql" "C:\Users\username\Documents\My Dropbox\mysql"
Explanation: mklink.exe is the program, “/J” parameter specifies “Junction points”. The first path is to the MySQL hard link. Next one is the current path of the moved mysql folder, inside the dropbox.
-
Start the servers.
Option 2 : Using a USB Flash Drive
Okay, this is not really syncing. I agree.
XAMPP has a portable mode that can be run off a flash drive. Let us install or turn the already installed XAMPP into portable application. First, stop the Apache and MySQL servers by opening “xampp-stop.exe” application located in XAMPP root directory.
-
Reliable, fast USB flash drive is needed. Also an reliable USB HD would do just fine. Format it (NTFS recommended). You can do this either in Windows explorer or with an advanced tool like HP USB Disk Storage Format Utility.
-
Move the XAMPP directory to the flash drive. If you encounter errors while moving, then probably servers are running, or it might be that the directory is locked (try Unlocker). Also make sure that no browsers are accessing the server ATM.
-
Run “setup_xampp.bat” located in the XAMPP root directory. It informs you that the directory name configured and current directory do not match.
-
when asked whether to relocate the files, Say Yes by pressing “y”.
-
Here we go. A full blown server environment in our pocket. Great!
Option 3 : Best of both
Well, if you haven’t thought it already, here it is. Both of the above.
-
Install the XAMPP in a USB disk and choose portable mode.
-
Sync the htdocs and mysql folders with dropbox.
Well, it works out for me. My work is double safe. Safe from loss, safe from me.
One thing though. MAMP does not have a portable mode. Poor iMac.
This is Part 3 of the Local server series.
Part 1 : Installing Local server in Windows using XAMPP
Part 2 : Installing Local server in Mac using MAMP
Part 3 : Complete Guide on syncing MAMP and XAMPP, this article.
Thank you, I appreciate your criticism
Kavin Gray

Pingback: How to install portable local server on your windows PC using XAMPP | Capability , .
Pingback: Installing a portable local server in your Mac using MAMP | Capability , .
Pingback: Darel Philip
Pingback: Darel Philip
Pingback: Integrating XAMPP’s web root (htdocs) and Dropbox « Lance Mohring
Pingback: Integrating XAMPP’s web root (htdocs) and Dropbox « Lance Mohring
Pingback: Syncing Mac and Windows WordPress Development - Jean Galea | Web Designer and Developer in Malta | WordPress Consultant