Menu Search
Jump to the content X X

Today, too many websites are still inaccessible. In our new book Inclusive Design Patterns, we explore how to craft flexible front-end design patterns and make future-proof and accessible interfaces without extra effort. Hardcover, 312 pages. Get the book now →

Developing WordPress Locally With MAMP

Local development refers to the process of building a website or Web application from the comfort of a virtual server, and not needing to be connected to the Internet in order to run PHP and MySQL or even to test a contact form. One of the most annoying parts of development, at least for me, is the constant cycle of edit, save, upload and refresh, which, depending on bandwidth and traffic, can turn a menial task into a nightmare.

With application platforms such as WordPress, which require a server back end to work, you would normally be constrained to develop on a live server, with the headaches that go along with that. MAMP1 and its Windows counterpart, WAMP2, are tools that allow you to locally develop applications that require a server on the back end.

The Local Server Link

MAMP, which stands for Macintosh, Apache, MySQL and PHP, is an application that allows you to install a local server-type environment in order to construct websites that would normally require you be on a live server somewhere. Ever opened a contact form in a browser from your desktop and wondered why it doesn’t work? The server-side components cannot operate without (in this case) the PHP back end, and this is where MAMP comes in. By installing this application, we can have a virtual server locally as our development sandbox. It is worth noting, from a portability standpoint, that this component can be run only from your desktop environment and cannot be installed on a USB drive. With that all settled, let’s get to it.

In order to be able to work with MAMP, we must first obtain it. So, head over to the project page3 and download the disc image. Double-click to begin the installation, and you will be presented with a choice:

MAMP Installation Screen
MAMP and MAMP Pro are on the installation disc image.

Both MAMP and MAMP Pro come in the same download. You need to install only one, and for most scenarios, MAMP is more than adequate. The pro version costs $59.00 USD and offers more options, and you can compare the two versions for yourself4.

Drag the MAMP folder onto the “Application” shortcut, and the installation will be underway. Once it’s completed, feel free to eject the disc image. Open up your “Applications” folder, and locate the new MAMP directory. Inside you’ll find, so — you guessed it — open it up. The program should start right away and open up your default browser, pointing to the start page. Congratulations, you now have a local server!

Preferences Link

From the main MAMP app screen, you will notice a “Preferences” button. Feel free to click on it to view the few options available.

MAMP App Screen
The MAMP app.

1. Start/Stop Link

From here, you have the option to tell MAMP when to start and stop the servers. If you choose to not start the servers automatically, then you will need to explicitly tell them to run each time you open the app. You may also set your home page, which defaults to the MAMP start screen, giving you quick access to phpMyAdmin; but you may set it to something like a WordPress directory.

MAMP Start/Stop Screen
Configuring the server.

2. Ports Link

In the “Ports” tab, the default Apache port will usually be 8888, and the default MySQL port will be 8889. I, for one, do not change these because they do not interfere with any of my other settings and do not require me to enter my password every time I start and stop the servers. You must include the port number in your URL this way; so, it would be localhost:8888/. To avoid this, you could change the ports to what general Web servers operate on: ports 80 and 3306. This will allow your URL to simply be localhost/; but you will most likely need to enter your password when switching the servers on and off. Another factor to consider is whether you are installing WordPress “multisite”; if you are, then you are required to set the ports to the default Apache and SQL ports of 80 and 3306, respectively.

MAMP ports setup
Setting up MAMP ports.

3. PHP Link

The “PHP” tab allows you to choose which version of PHP to run in the set-up. It will default to 5.3, and I do not change this because most applications I run either require PHP 5.3 or do not care. Just know that this option is available if you need it to run something such as legacy software.

MAMP PHP setup
Setting up the MAMP PHP version.

4. Apache Link

The “Apache” tab is one that I like to mess with, to change the document root directory. The root is where all of your websites and directories will be stored and accessed by MAMP, and it defaults to /Applications/MAMP/htdocs, which I find annoying to get to. So, I change mine to my sites folder. From the MAMP app window, click on “Preferences,” then on “Apache.” You can click “Select” and then set the installation to use the location of your choice for your websites. Again, I set mine to the sites folder for easier access.

MAMP Apache setup
Setting up MAMP Apache.

Installing WordPress Link

Now it is time to install WordPress. Head to the WordPress website5 and download the latest version, 3.2 as of this writing. Unzip the folder, and then simply drag it to your sites folder, (or wherever you chose to set the document root for MAMP). WordPress requires PHP and MySQL to operate, which is why we needed MAMP to develop locally; so, we now need need to make a database. Fear not: it is simple!

Open the MAMP start page — you can access it via the button in the main app — and click on “phpMyAdmin” in the top menu. Creating a new database is as simple as typing a name in the field and hitting the “Create” button. You can see below that I am creating a new database aptly named “wordpress.” Once that’s done, feel free to close phpMyAdmin, and navigate to the WordPress directory in your document root.

Creating the Database
Simply type a name for the database, and hit “Create.”

Basic Configuration Link

Find the file named wp-config-sample.php, and open it in your favorite text editor. We have to configure a few settings. The default values for MAMP installations make this really easy to fill out, so follow the table below to see what to type where:

Variable Value
DB_NAME wordpress
DB_USER root

Editing Variables
Change the values of the variables to match the table above.

You should not need to alter anything else in this file, at least for now. You could add in the unique keys and salts, but I recommend doing that once you move the website into production.

Save and close wp-config-sample.php. We’re nearly done. Rename this file to wp-config.php — removing the -sample — and we are ready to complete the installation. You should now be able to point your browser to http://localhost:8888/wordpress and see the WordPress installation screen. Enter in your basic data and install the app. You are now ready to log into the admin section and get going!

WordPress Install Screen
Enter your information… but choose a stronger password.

Always follow WordPress’ permalink structure. In order for you to get these “pretty URLs6,” Apache will need mod_rewrite to update your .htaccess file, so let’s make sure that is set up.

The file we have to edit is httpd.conf, and you can find it in Applications → MAMP → conf → apache → /. Open this file, and search for a line like this:

LoadModule rewrite_module modules/

Note that a hash (#) may or may not be in front of it. The hash indicates a comment, and if you see it, you must remove it to allow the mod_rewrite module to load. If the line is not commented out, then congratulations: you are already done! Close the file, and permalinks should now work in your local installation.

The Final Countdown Link

By now, a local server set up with WordPress should be installed and running. The remaining steps are both short and crucial to sharing your creation with the Internet. All that remains is to transfer your local accomplishments to a global environment by moving both our WordPress files and our content. So, let’s finish this up!

Going Live Link

The time has finally arrived. So, how do you bring your WordPress creation to the live server? Well, we have two options.

Just Grab the Content Link

A sometimes simpler way, with only a few steps, is to just grab all of your content. This is easiest if WordPress is already installed and you just need to import your theme and content. To do this, head to the admin dashboard, to the “Tools” section in the sidebar. Click on “Export,” and choose “All content.” This will export a file that you can then import into your new installation.

WordPress Content Export
Exporting WordPress content.

You can now upload your WordPress theme files to the live location. Head to the “Tools” section of the dashboard again, and choose “Import.” Simply point to the file that you just exported, and bring in your content.

Bringing In Everything Link

I use this method if I have done everything locally from the ground up. I’ll upload my entire local WordPress directory (in this case, http://localhost:8888/wordpress) to the live server and then grab the database file and transfer that from local to live as well.

Because you could certainly build nearly the entire website in your development environment, bear in mind that WordPress uses absolute paths for URLs. So, every image and link will be prepended with http://localhost:8888/ (depending on your set-up). We need a way to alter this to fit the live website. We have a few options.

1. Export, Search and Replace Link

Using this method, we export our local database as a text file and run a “Find and replace” on the text to replace all occurrences of the localhost URL with the production URL.

WordPress Database Export7
Exporting the WordPress database (click image for full-size view).

Begin by opening phpMyAdmin and clicking on your WordPress database on the left. Click on the “Export” tab in the top menu, and be sure to choose “Select all” when choosing which tables to export. At the bottom, check the box to “Save as file,” and then hit “Go.” Open the resulting file in your favorite text editor, and simply run a “Find and replace” to replace all instances of http://localhost:8888/wordpress with

Save the edited file, and visit phpMyAdmin on your live server. Again, click on your WordPress database, and this time choose the “Import” option from the top menu, and browse for your newly edited file. Once it successfully imports, upload your WordPress directory to the live server. If WordPress is already installed, simply upload your theme, any plug-ins you have installed locally and the contents of your wp-content/uploads folder; or else, upload the entire local directory to your live website’s root. Once that’s uploaded, be sure you can log into wp-admin, and browse around to make sure everything made it in. Update your permalink’s structure to something friendlier, and you are off!

2. Using SQL Queries Link

A second way to alter URL paths is to first bring everything into the live server version, and then use a few SQL queries to find and replace the necessary strings. Open phpMyAdmin on your local server, and export the database, again making sure to select all tables and to save it as a file. Go to your live server, and import the .sql file that you just saved. In the top menu, click on the tab for “SQL,” whereupon you will see a text area. You will need to enter some query syntax; be sure to replace the URLs in these code fragments with the ones that pertain to your set-up — namely, the localhost’s path and the URL of your new live website.

SQL Query Screen8
Running SQL queries to update the URL paths (click image for full-size view).

Replacing WordPress’ base URL path:

UPDATE wp_options SET option_value = replace(option_value, 'http://localhost:8888/wordpress', '') WHERE option_name = 'home' OR option_name = 'siteurl';

Update the GUID that controls WordPress’ translating paths and post locations:

UPDATE wp_posts SET guid = REPLACE (guid, 'http://localhost:8888/wordpress', '');

Update the URL paths in the content:

UPDATE wp_posts SET post_content = REPLACE (post_content, 'http://localhost:8888/wordpress', '');

Update the URLs in the meta data of posts, such as attachments:

UPDATE wp_postmeta SET meta_value = REPLACE (meta_value, 'http://localhost:8888/wordpress','');

Final Thoughts Link

We have managed to install MAMP to set up a local server sandbox9 to develop in, and we’ve configured and installed a WordPress platform to develop in, saving the need for purely online development tactics.

I hope this has given you some insight into setting up a local environment to work with WordPress. Keep in mind that this is just scratching the surface; WordPress is versatile. Now that we have this faster new way to develop, the next time we’ll get into some custom WordPress configurations.

You may be interested in these related resources:


Footnotes Link

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14

↑ Back to top Tweet itShare on Facebook


Ryan is a front-end developer who believes in an enjoyable web for all and created BrowsingBetter. He loves WordPress, jQuery, learning new web skills, and short walks far from beaches. Check out his newest project TextMateUser and tweet with him @ryanolson.

  1. 1

    You could also use Bitnami’s pre-configured WordPress stack. They offer a virtual and cloud hosted version as well. I use them for starting/testing a number of applications.

  2. 3

    Not sure if there is something similar for Mac, but I used to do the same process as above with XAMP until I found Instant WordPress. What a time saver!

    • 4

      I have used XAMPP on windows for over a year now. In addition, XAMPP has a portable version you can put on a USB – very useful.

      • 5

        Artur Czyzewski

        September 29, 2011 6:54 am

        Xampp rulez! Portable version is really nice when you work on your home pc. There is no need to install services such as MySQL pernamently so they arent impact on your pc memory and performence.

  3. 6

    I use this setup to develop and it’s great.

    One thing that always bugs me is installing plugins – does anyone know a foolproof way of getting rid of the ‘Enter your FTP server details’, or what I should actually put in there?

    • 7

      I’ve only ever seen this on my live server – on any WordPress install on MAMP all plugins and themes simply download and install themselves by default – no FTP details required. Not much help I know, but it can be done!

    • 8

      @Tommy In MAMP Pro, in the Server > General pane, under “Run Apache/MySQL server as a user” you should be able to select “yourname/yourname” from the dropdown select box. MAMP displays a security warning, but I think it’s worth switching to just for the sake of installing WP plugins. You can switch it back to “www/mysql” when you’re thru installing plugins. I hope this work-around works for you as it does for me.

    • 10

      Kasper Bergholt

      September 29, 2011 3:08 am

      Hi Tommy!


      To the bottom of your wp-config.php.

  4. 11

    Question: What is the difference using WAMP vs XAMPP? I’ve been using XAMPP for a couple of years & it suits me fine…

    • 12

      Yentl (Design 311)

      September 28, 2011 11:02 am

      I’ve been using XAMPP as well, I haven’t encountered any problems with it, so I wouldn’t say that it is unstable in any way. The main difference between WAMP & XAMPP is the extra P, of course, which stands for Perl, XAMPP installs Perl as well, WAMP doesn’t.

    • 13


      I have never used XAMPP but a quick Google on it says a lot of people are like you, perfectly happy with it. Seems to be a smaller setup, and cross platform, however not quite as stable and secure as its WAMP and MAMP counterparts.

      Again, that was just a cursory search ;)

      • 14

        You DO know that php and Apache are installed by default on OSX right? All you have to do is go into System Preferences->Sharing, and turn on Web Sharing.

        For MySQL, you can just download a DMG from the official website, and a preference pane, and you’re all set. There’s no reason to install ANOTHER copy.

        • 15

          Justin St. Germain

          September 28, 2011 12:06 pm

          i was going to say the same thing. and if you really want PHPmyAdmin, like i do, then you can install it locally too, so, no point in getting MAMP. Although, MAMP does make it easier and quicker to set up a localhost for the people that dont know how to do the rest.

        • 16

          PHP is installed and the process of activating the built in server is simple. However, PHP is not activated by default, and has to be turned on by the user by editing a hidden core file (you basically just have to uncomment the line that activates PHP). Simple, yes, but can be daunting by some people. You would also only have the option of testing with version 5.3.6 (in Lion anyway). But once it is set up it is very easy to use. MySQL installs easily, and I use MYSQL GUI Tools which set up easily as well. That’s what I use for all my local development with WordPress and such.

        • 17

          I used the default install of PHP/MySQL/Apache on OSx, but the problem is that being a developer I can’t be bothered setting it up and having to research for problems if any are encountered.

          I use MAMP Pro, which is great as it has everything I need in one place for my Virtual Hosts, PHP Versions, PHPMyAdmin, dyndns & Postfix settings and other tools.

          I know it’s not hard to set up correctly, but I don’t want to have to go in and configure the web site by going into x files to amend the details. MAMP has the basics in one place and MAMP Pro has all the advanced parts in the same place too, like error logging and displaying, virtual host set up and such preferences.

          This is a great tool that is enjoyed by many front and back end web developers for the ease of use and setup. I know a few developers that are great back end developers but do not want to touch the inner workings of OS x. With MAMP/ MAMP Pro you can play around all you want & if you break it, you re-install it… Simple :)

          @Ryan: I am liking you’re browsingbetter & textmateuser sites. I have been using Netbeans recently as being an IDE, it gives me a one stop shop for everything. I was wondering if you knew what features where coming to TextMate 2 as I do still use this occasionally.

          • 18

            Hey smilinmonki666 thanks for the comments,

            I have no info on what is coming in TM2, but I assure you as soon as I can squeeze some out I will post it :)

        • 19

          Jasper Van Proeyen

          September 30, 2011 5:45 am

          Even a better reason to use the built-in PHP and MySQL on Mac OS X: once you get the hang of it you can make use of virtual domains (e.g. If you have Windows installed via Parallels, you can make use of the same virtual domains there and test your websites in various versions of Internet Explorer (all locally and live) – and yeah, other browsers too ;-)

          • 20

            You don’t have to use the built-in Apache+MySQL+PHP on the Mac in order to take advantage of virtual domains. I do this all the time with MAMP.

            You just have to edit your Hosts file to point your custom domain to the localhost.


            Then add your virtual domain to the bottom of the httpd.conf file found inside of the MAMP installation.

            Works great, and you can still test with VMWare Fusion or Parallels by editing the hosts files on your Windows installations, which really comes in handy.

          • 21

            Jasper Van Proeyen

            October 3, 2011 11:32 am

            I know, thanks! But AFAIK you can’t test them in Parallels then.

  5. 22

    Good thorough article, bookmarked.

  6. 24

    Nice post Ryan.

    I have a request thou.

    Dear Smashing Magazine! It would be nice if someone gave a nice article on how to work with MAMP, WordPress, etc. and Subversion working locally and uploading/updating your site on cloud/host/web etc.

    I think this would be a nice tutorial.

    • 25

      Thanks Alex!

      I have never worked with Subversion before, perhaps I can look into writing one using Git…

    • 28

      Hi Alex!

      I am actually in the process of writing up the exact article you need I think :) It basically describes creating a custom WordPress install using SVN alone (having all plugins version controlled as well and so on.)

      I was actually half way through writing this exact article when I saw it published so THANKS RYAN! :) Seriously though, awesome article, this is almost exactly how I do local tests if I’m not using version control.

      The only additional thing I do (I think it is mentioned in comments below) is that I use virtual hosts to enable roots like http://mytestsite/ instead of http://localhost/testsite/ This enables me to use htaccess rules and other things without subdirectories.

    • 30

      I am currently writing a tutorial on setting up a Linux Box & OS x box with:
      MySQL Sync between 2 servers

      plus some other toys….

      Git is easy to set up on OS x or any other OS for that matter, you just need to read up on it to really understand the concept so you get better usage from it. I prefer to SVN as it seems more stable. For a team of 5+ using SVN, we seem to have a few problems.

  7. 31

    Wow, nice tutorial… Helpful if you are using wordpress and ur website is under construction, develop it locally n launch in a shot.

  8. 32

    anyone know more about the guid field update?

    the codex seems to say NOT to change it, EVER:

    • 33

      Yes, I was thinking about that too. From what I understand, changing the GUID won’t ever break your site, it just has the potential to interfere with feed readers.

      Since you are only developing locally at this stage, posts will not have been aggregated by feed readers on the web and so there won’t be the issues outlined in that codex article.

  9. 34

    I know this is completely preference, but because of the way WordPress relies on the fully qualified domain name I’ve found it easiest to simply edit your hosts file so that your computer resolves whatever domain name your developing for to your computer.

    If you open terminal you can type sudo vim /private/etc/hosts or as a textmate user I type mate /private/etc/hosts which opens the hosts file. Add – as long as you’ve got the site configured in your virtual hosts file, when you go to it resolves local.

    So when you push your site up, it’s as simple as exporting/importing your database (Sequel Pro makes this even easier then PhpMyAdmin – but the tool you use is up to you), and copying your files to your server. You may need to change your database settings, but that would be it.

    • 35

      Good point Jason, thanks for your input.

      As you said, definitely a preference as there is by no means only one way to do something. MAMP Pro also offers the ability to set up virtual hosts quite easily, which is something worth looking at as well, though beyond the scope of this tutorial. ;)

    • 36

      If you’re uncomfortable editing your hosts file I find that VirtualHost from clickontyler works great on the Mac. As Jason says this means that you can use the final url locally for development so that you don’t have to search and replace the dev urls for the final urls in the WP database at launch time. btw there is also a version on the site that will run on Leopard.

    • 37

      You can also manage your Apache files with TextMate via the Bundles menu….

  10. 38

    A third way to update URLs in an SQL file is by using cat and sed, two command line utilities. To replace all occurrences of “” with “,” use:

    cat /path/to/file.sql | sed ‘s/’ > path/to/file/new-file.sql

    The result, new-file.sql, is created in seconds with your URLs updated. Using this approach versus TextMate’s Find and Replace functionality saves time and hassle. No spinning beach ball.

    See the man pages for sed and cat for more details. Open up that command line!

  11. 39

    This is a good setup for local dev but it is a lot of headache when moving from local to production. A better way to handle that is to use something like SVN or GIT.

    Then modify your hosts file and vhosts file so your local environment will match the remote environment. Then you can install your wordpress on the remote server and point your local machine to the remote database.

    Using this setup it is possible to develop locally and when your done push your changes up with SVN never having to touch FTP and never having to worry about changing your database once you set it up the first time on the remote server.

  12. 40

    Thanks Ryan for your post. I use a similar set up with VirtualBox and Ubuntu server. My main issue is moving WP from the dev environment to the live server. Does anyone knows why on earth WP uses absolute paths for URLs and stores them in the DB? It drives me crazy! What’s the reason for it? I can’t believe that I have to run sql queries to clean up the mess and update the tables with the right URL. IMHO, it just seems a bad design to me.
    Anyhow, thanks for your clear step-by-step guide on how to fix this.

  13. 41

    If I had 3 wordpress sites I was working on simultaneously can you develop multiple sites using the one MAMP configuration? I’m not quite clear.

    • 42

      Hey Peter,

      Do you mean a WordPress Multisite setup? Or simply three different WordPress installs?

    • 45

      You can use a local MAMP set up to run as many individual WordPress sites as you need. Simply configure a separate MySQL database for each, and set up a separate site for each.

      This is also true for mulitsite installs. However, as mentioned above, WordPress multisite is very dependent on domain names. With MAMP, you can either manually edit your hosts file, or pop the $50 for the Pro version which does it for you. I develop nearly everything locally, using the Pro version and by using the altered hosts file, the actual domains to which the sites will launch. This way there are no surprises when I deploy to production. I then can simply export/import the db, then prop over the files. If the database is set up locally with the same info as the production system, the wp-config info stays exactly the same and it is a fast and simple process.

    • 46

      I never had problems working on several WordPress sites with MAMP. I just create a new database for each new site. Be aware though that all the sites have to be found by MAMP at the path you specify in Preferences/Apache. May it be users/you/all-sites/ so, under “all-sites” you will have:

      (hope is clear)

      Instead, I would really like to read more about Subversion with WordPress, and WordPress multisite with MAMP.

      Last thing, Ryan, why you open the config-sample.php? Isn’t WordPress 3.x providing a front end interface for setting this up, during the installation process? Maybe I’m missing something.

      By the way, thanks for the article :)

      • 47

        Hey Carlo,

        I would like to learn more about version control with WP too ;) So that is on my list to study. As for a front end set up interface, to be honest I do not know I am so used to doing it the config.php way!

  14. 48

    Hey Ryan, thanks for your article. I would love hear something more about what is the upside/downside of using MAMP instead of a built in apache/php?

    I understand it’s a all in one package which makes the environment setup/usage a lot easier for a lots of people, but that’s not the answer I’m looking for :) So, why do you consider using MAMP better as native environment?

  15. 49

    John Surdakowski

    September 28, 2011 10:52 am

    Ive been using MAMP for the past year. GREAT for testing locally. This article explains it all.

  16. 50

    Hi. Unfortunately, Wamp is completely out of date (nothing since sept. 2010) and Xampp is not friendly at all. Personalty, I prefer EasyPHP ( : up to date (even with PHP 5.4.0 beta), it comes with modules like WordPress, Drupal, Joomla… (no need to follow the tutorial above you just need to run the module setup – 2 minutes and it’s done) and you can control everything (admin for alias, virtualhosts, php and apache configuration, Xdebug…).

  17. 51

    Good article, personally I use MAMP for almost two years without any problem.

  18. 52

    Rizqi Djamaluddin

    September 28, 2011 8:13 pm

    I’m going to drop this in here:

    Sometimes, because of certain situations, WordPress/MAMP can manage to misplace a .htaccess file, leading to certain directories (such as phpmyadmin) becoming inaccessible. Clearing the htdocs folder, or even reinstalling MAMP, won’t help.

    If this happens, check your root hard disk folder – often, the .htaccess file somehow ends up here.

    I just had this happen, so hopefully this comment will pop up if anyone has this happen.

  19. 54

    The pro version costs $59? Looking at the feature set there are additional things but I just don’t think it has anything I’m dying to have. XAMPP is free and I cannot find a reason as to why you’d need anything more for running php, mysql, mail, ftp etc locally. Comes with phpMyAdmin, xDebug (windows version) etc.

  20. 55

    Thanks for the roundup.
    I use the mysql search&replace method and noticed several widgets deleted when moving sites (WP 3.0 and greater). Did anyone else notice some issues with widgets after WP has moved?


↑ Back to top