Local WordPress Development on Multiple Machines

Working with WordPress on a local machine can be frustrating if you frequently use more than one computer.

I’ve seen a few blog posts where developers will set up two MAMP instances and then sync their database files with Dropbox so they can access the same database file on both machines. This is tricky to set up and can easily lead to corrupted database files.

Instead of using the MAMP provided local database, I use a database on my web host account and store all the WordPress files in DropBox. Here are the steps:

Setup

  1. Install MAMP on both machines.
  2. Once MAMP is set up, go to MAMP Preferences -> Apache and change document root to your Dropbox folder or a Dropbox subfolder. For me it’s: /Users/Kevin/Dropbox
  3. Ensure you change this setting on both machines
  4. Now create a database on your hosting account (I currently use Namecheap hosting).
  5. Be sure to enable remote access to MySQL. If you’re using a shared hosting account and cPanel, click on Remote MySQL

WordPress Installation

  1. Download WordPress and unzip it
  2. Place the unzipped WordPress folder in your Dropbox folder
  3. Start MAMP
  4. Go to: http://localhost:8888/ (This may be different if you changed your default MAMP port settings)
  5. Click on the WordPress folder
  6. You should get the following WordPress wpconfig.php setup screen:

    create wp-config.php file

    Create WordPress wp-config.php file

  7. Now create the wpconfig.php file. The tricky part is figuring out the correct credentials for remote login to your hosted server. Here is an example if you’re using BlueHost:

    Remote database settings

    Remote database settings

  8. If you’re using a shared hosting account, you may need to prefix your database name and username with your username. When you create your database and users from your cPanel, you should see something like: username_databasename. For example: kcm_wp1
    Your username would then be something like: kcm_user1
    And you may need to use an IP address in the Database Host field.

The only downside to this arrangement is that it’s not quite as fast as a local database.

It’s really good practice to install multiple instances of WordPress on your local machine using different scenarios. It makes the real life installation second nature.

19 thoughts on “Local WordPress Development on Multiple Machines

  1. Joel Stransky

    I’m trying to do this using xampp and mediatemple’s gridserver.
    I’ve white listed my IP, created the database and given my user privileged to access it. When using the correct url mediatemple prefers you to use when accessing an external database I get the first page of the install screen to appear. After I fill out the site name, admin log and pass and click install, it spins for a bit then only loads a portion of the success page (basically just the wp logo). I can then login but only see Dashboard and Profile in the menu. Something is failing but I have no idea what. Any ideas?

    Reply
    1. Kevin Marsden Post author

      Hi Joel, I haven’t tried this with Media Temple, but I’m assuming it’s because of the way their servers are set up. I’m pretty sure they have a different setup than the standard shared hosting setup. Sorry I don’t have more details to help.

      Reply
      1. Joel Stransky

        Thanks Kevin,
        I seem to get normal access to the admin after the failed table creation so I’m thinking I might just be able to do the install all on the server and then move my project to my local machine. I’ll reply after I’ve tried it.

        Reply
  2. Enzo

    Great tutorial Kevin! Worked a charm…
    What would I do once I’m ready to move the site online? (to the same hosting where I created the database)?
    Cheers,
    Enzo

    Reply
    1. Kevin Post author

      The issues are similar to most local to production migrations. You’ll definitely need to search and replace any mention of your local URL in the database (mine is : http://localhost:8888/SITE_NAME). Then you’ll need to FTP everything in your local wp_content folder up to your production server. I don’t do this very often, so I may be missing a step 🙂

      Reply
  3. Darren

    Great post and excellent tip, I’ve been trying to figure this out for a while as I have 3 different machines I develop on….

    How do you get around the local ip address issue where image and URL paths stored in the db are pointing to the originating IP address?

    For example, I set up a site at the office, where my ip address is 192.168.x.x:8888, but then my home machine is 204.168.x.x:8888 – On my home machine I would get 404s as the ip address is not available.

    I can access the DB, but all links and images would be pointing to the other IP.

    Does that make sense?

    Reply
      1. Darren

        Ahh right! I should be using localhost:8888…
        I forgot about this as had been using my local IP address at the office to enable co-workers on the network to view my machine at 192.168.x.x:8888.

        Thanks again for the tip!

        Reply
  4. Ashley

    This has been so helpful Kevin.

    I’ve gotten it to work just fine on two separate PC’s.

    But I can’t get it to work on my Macbook.

    The problem seems to be that all of the WordPress files don’t have the correct read/write permissions. I’m using Google Drive instead of Dropbox, not sure if this is the source of the problem?

    Do you have any light to shed? Thanks.

    Reply
    1. Kevin Post author

      That’s a really good question. I don’t use Google Drive much, so I’m not sure what the problem might be. If you figure it out, please let me know. Cheers!

      Reply
      1. Ashley

        I just tried it on Dropbox and got the same problem.

        In my browser, at locahost, I’m getting this error message: “Access forbidden! You don’t have permission to access the requested directory. There is either no index document or the directory is read-protected.”

        When I check the permissions on the directory, it says that I (as a User) have read-write permissions, but that “everyone” has read-only. I changed “everybody’s” permissions to read-write, but that had no effect.

        Stumped…. 🙂

        Reply
        1. Kevin Post author

          Hmm. That’s strange, because most issues resolve around remote database access.

          My new shared host doesn’t allow remote MySQL connections, so I haven’t tested this method lately.

          I’m sorry that I’m not more help. Let me know if you’re able to figure it out.

          Reply
  5. Shaun

    Hi guys,

    I am a beginner currently developing a website at work in wordpress locally on a mac (MAMP server). I need to install it to another laptop (with a double boot with zorrin or windows) so that my colleague can access the site and make changes. Any suggestion how to proceed from here?

    Any help will be kindly appreciated.

    Cheers
    Marc

    Reply
    1. Kevin Post author

      I don’t really recommend this method for a team dev workflow.

      Instead, you can each maintain your own development environments. The key is to use version control (Git or SVN) to track the changes each of you make to the source files and ensure that both of you are working from the latest changes. Most of the changes you make won’t affect the database, so as long as you both start with the same dummy content, there shouldn’t be a need to sync the database. You can also something like Backup Buddy or Desktop Server to ensure that you’re both starting with a similar dev site.

      Reply
  6. Dan Goldsmith

    Hi Kevin
    I’m having a bit of difficulty doing this too, but I think I’ve covered the correct steps, can you spot any mistakes…

    1) For now rather than put the WordPress folder in Dropbox, (where I will eventually move it to), I’ve just left it in my mac Docs folder. I’ve called the WordPress folder wptest for the purpose of testing how this works.

    2) I’ve then opened my online cPanel – created a mySQL database and password.

    3) Gone into Remote MySQL – added my office computer IP address, all good so far….
    and I get back a Remote Host URL and told to access on port 3306.

    3) So I then go to my local MAMP 6.0,
    (i) link the correct document root, users/docs/
    (ii) leave the NIGX and Apache Ports set to 8888, but alter the mySQL port to 3306 and start up the MAMP server. (All Green – good).

    4) Then type – localhost:8888/wptest….. which opens the welcome to WordPress choose your language page – choose UK ENGLISH and move forward to – locate your database.

    Again all good so far……

    5) Fill out;
    Database Name: SAME AS THE MY SQL USER

    User Name: MY SQL USER

    Password: MY SQL PASSWORD

    Host: Change LOCALHOST to the HOST URL supplied my cPanel remote access.
    (This is where I think it all goes wrong).

    And move forward to the next page, expecting the usual ALRIGHT SUNSHINE PAGE….
    But instead, I get…

    Failed to connect to the database.

    Any ideas why this isn’t working, I’ve left a support ticket with my cPanel host provider to check if I can actually remotely access the MySQL area. (and am awaiting a reply)…
    But can you see any reason why this isn’t working or any steps i’ve missed?

    Cheers
    Dan

    Reply
    1. Kevin Post author

      Hi Dan,

      Those steps look correct. One thing I recommend doing is testing the remote database connection with a database management tool like TablePlus or Sequel Ace. If you’re able to connect, then there’s likely an issue with the db settings in WP.

      Reply

Leave a Reply to Ashley Cancel reply

Your email address will not be published. Required fields are marked *