You are Viewing : HomeAppleComplete guide on syncing XAMPP and MAMP using Dropbox

Complete guide on syncing XAMPP and MAMP using Dropbox

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
  • Sync development files acrosss multiple operating systems.
  • Cross compatibility between operating systems.
  • No fear of loosing all the hard work. Our work is safe.
  • Only htdocs folder is synced.
  • MySQL databases cannot be synced when running Multiple OS.
  • Need independent server installations in each computer.
  • Internet connection is needed for committing the changes to the online dropbox once work gets done.
USB Flash Drive
  • complete server environment with us, anywhere anytime.
  • No cross compatibility with other Operating systems.
  • Chance of USB flash drive failure or even chance of misplacing it.
  • xampp servers cannot be run as services in portable mode.
USB drive + dropbox
  • Advantages of both methods above.
  • Lessens paranoia.
  • More awesome.
  • MAMP does not have a portable mode. A heavy drawback.

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

  1. We move the htdocs folder (located in XAMPP root folder) inside the dropbox folder.
  2. Then we create a hard link named exactly “htdocs”, which points to the “htdocs” folder inside the dropbox.
  3. xampp server takes the htdocs hard link for a real folder, while MAMP allows us to have the htdocs anywhere on the disk.
  4. Remember, you need to have databases with exact same name, in each local server. For e.g. Say we have wordpress 3.0.1 with it’s database named “wordpress”. So, it is necessary to have a database under the exact same name “wordpress” in all the local servers.

Before you start, setup Dropbox and make sure it is working.

↑ Top

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.

mklink

mklink.exe usage

junction

junction.exe usage

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

  1. Locate the xampp folder.
  2. Stop the xampp server. Use the “xampp-stop.exe” in the xampp root folder to do so.
  3. Open the command prompt. (Press keys  Windows + R –> type “cmd.exe” and press enter”)
  4. we move the “htdocs” folder inside the dropbox folder.
        1. Say, we have the xampp installation in the path “D:\xampp” with “htdocs” folder inside it.
        2. we move it into the dropbox (located in “C:\Users\username\Documents\My Dropbox\htdocs\”)
        3. 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 Dropbox : Syncing files now. to the All done icon Dropbox : All files up to date ). 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.

↑ Top


Syncing MAMP with Dropbox

  1. No need to fiddle with hard links, because MAMP allows us to have our “Document Root” (htdocs) anywhere on the disk. Cool!
  2. Open the MAMP application and Click “Preferences”.
  3. Go to the tab “Apache”.

  4. Change the Document Root to the path of the htdocs in the dropbox folder. Click OK.
  5. Stop and Restart the servers.

↑ Top

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.

  1. Backup your entire XAMPP directory. Seriously.
  2. Make sure the servers are stopped. If not, stop the servers using “xampp-stop.exe”.
  3. Move the “mysql” folder to your dropbox folder.
  4. 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.

  5. After this is done, check the dropbox syncing icon on the tray. Let the syncing finish. drop_sync to  drop_ok.
  6. 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.

  1. 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.
  2. 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.
  3. Run “setup_xampp.bat” located in the XAMPP root directory. It informs you that the directory name configured and current directory do not match.
  4. when asked whether to relocate the files, Say Yes by pressing “y”.
  5. Here we go. A full blown server environment in our pocket. Great!

↑ Top

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 , .

  • http://www.wh-tech.com/ WH-Tech

    Wonderful article post on the blog bro. This particular is just a tremendously nicely structured blog post, just the data I was looking just for. Thank you

  • Pingback: Darel Philip

    • http://kav.in kavin

      Thanks Darel :-)

  • Pingback: Darel Philip

  • Tim Cox

    Thanks for the article.

    I’m running windows 7 so have followed your instructions to use mklink. It works fine and creates the folder in my htdocs folder and I can see the files in there (even though there is a padlock symbol). When I then go to run the site as per normal e.g. http://localhost.sitename the following errors appear:

    Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0

    Fatal error: Unknown: Failed opening required ‘C:/xampp/htdocs/foldername/index.php’ (include_path=’.;C:\xampp\php\PEAR’) in Unknown on line 0

    any ideas?

    • http://kav.in kavin

      Hai Tim, I may need some additional info regarding this.
      To access your site, you have to type “http://localhost/sitename” with a forward slash between. Also please check whether your other php files are working. Go to “http://localhost/xampp/” , click “status” and look for any errors there.

      Try relocating the xampp files. To do that, please browse to the XAMPP folder, and open “setup_xampp.bat”. In the command window that appears, type “2″ key to start relocating. When asked about the Portable mode, press “n”. Now try again.

      Always top the xampp servers “XAMPP folder->XAMPP_Stop.exe” before performing any operation..
      Try this and let me know. :)

  • Caffeine

    Excellent article. One thing though, would it be possible to use the USB and Dropbox method (option 3) to sync across platforms? So if I use a Windows pc and a macbook laptop will it work? I’ve been reading that there are issues with the databases not syncing properly.

    • http://kav.in kavin

      Thanks! About syncing macbook and Win databases – possible, but no concrete method exists. For me it worked partially with XAMPP on both systems(my win PC and iMac). But DB problems did happen and were unpredictable. Underlying problem here would be binary incompatibility, as we can guess.

      I am stuck with an indirect solution – Sync the htdocs folder on both computers and auto backup the mysql DBs on the main computer to Dropbox sub folder. The second pc (here my iMac) checks for the DB backups in the dropbox, restores it.

      MySQL replication is an another option, but that is little too complex, not to mention an additional layer of maintenance. You can get the basic idea here

      • Caffeine

        Wow. You would think somebody would’ve come up with a solution to this by now. It sounds like an overly complex solution to something that seems simple.

        I think I’ll try what you mentioned but I’m not entirely sure how to restore a database using Dropbox so I may well be back here with more questions!

        Thanks for your reply Kavin

        • http://kav.in kavin

          You’re always welcome, pal.

          I always stick with Occam’s Razor. It should not be very hard to write scripts to do syncing at intervals on both sides. Well, maybe we could make the win server back up its DB to dropbox(numerous options to do so) – and Some Automator’ed App on Mac could sync it on the other end.

  • 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

  • http://www.facebook.com/jos.vanreenen Jos van Reenen

    You could just move your htdocs content to any folder in your dropbox and configure apache to use that folder as documentroot, see http://stackoverflow.com/questions/1408/make-xampp-apache-serve-file-outside-of-htdocs 
    This way there is no need for hardlinks whatsoever, just two edits to documentroot in httpd.conf in XAMPP_INSTALL_DIR/apache/conf