Navigation

Quick and Easy WordPress Development on a Mac with MAMP

Web Development, WordPress | Dec 20, 2008

Ready for some WordPress development on your Mac? First, you need to be running Apache, MySQL, and PHP.

Although Mac OS X comes with Apache and PHP, you don’t want Apple’s automatic software update to break your development environment by changing your working versions of PHP and Apache. Plus, do you really want to spend time tweaking MySQL?

In this guide, I will show you how to quickly install and configure a working WordPress environment including Apache, PHP, and MySql.

 

1. Turn off Web Sharing

First, you need to make sure the Mac OS X installation of Apache is not running. Navigate into your System Settings and check the “Sharing” settings. You want to turn off “Web Sharing” if it is currently enabled.

 

2. Use MAMP

MAMP is a free and ready-to-go install of Apache, MySQL, and PHP for Mac OS X. It is developed by Living-e. They also have a “Pro” version at additional expense. One of the great things about MAMP is that it includes almost every PHP option pre-installed and enabled. As a bonus, it comes with phpMyAdmin to help you work with databases quickly. To get MAMP, open up your web browser and go to http://www.mamp.info/en/download.html. Download MAMP, mount it, and then drag the MAMP folder into your Applications folder. You can safely ignore the “MAMP Pro” folder.

 

3. Configure MAMP

Go into the MAMP folder and then open the MAMP icon.


The status lights will tell you if Apache and MySQL are running. If the lights are red, click “Start Servers”. Next, modify the ports for Apache and MySQL by selecting “Preferences” and select “Set to default Apache and MySQL ports.” You should end up with port 80 for Apache and port 3306 for MySQL. Next, click on the Apache section and change the Document Root to a location that you can quickly access. All your websites will reside in this location, so you want to pick something that you can navigate into easily. I like to use a root folder called “webspace” that I created in the Finder.

 

4. Make a Database for WordPress

WordPress requires a MySQL database to store posts and settings. You already have MySQL running, but you need to create a separate database for each WordPress website that you develop on your Mac. From the main MAMP menu, click on “Open start page.” Your web browser should pop open up to a “Welcome to MAMP” page.

Next, click on “phpMyAdmin” to launch the phpMyAdmin web application. Look for the section entitled “Create new database” and name your database. As an example, enter “wp-superblog” and click “Create” to make a database.

 

5. Make a folder for your website

Within your “webspace” folder, make a new folder with the name of the website that you will be developing. As an example, make a folder called “super-blog” to correspond to the database you made.

 

6. Install WordPress

The easiest way to download WordPress is to point your web browser to http://www.wordpress.org/latest.zip Unzip the WordPress package and copy everything in the WordPress folder into your “super-blog” folder.

 

7. Configure WordPress

Navigate into your “super-blog” folder and locate a file called “wp-config-sample.php”. Open that file and change both the database username and password to “root” on lines 4 and 5. Next, make sure the name of your database (“wp-superblog” in our example) is shown on line 3. Save the changes you made to this file and then rename the file “wp-config.php”.

 

8. Take a Test Drive

Open up a web browser and navigate to “localhost”. You should see a folder for each website you are developing. In our example, you should see a folder named “super-blog”. If you click on it, you should instantly get to your new WordPress website.

 

9. Turning MAMP on and off

When you are not developing and testing a website, you may want to turn off Apache, PHP and MySQL. MAMP comes with a dashboard widget that will turn your environment on and off instantly. You can find the widget in the MAMP folder.

Written exclusively for WDD by Derek Underwood, a professional web designer and software developer. You can read more about Derek and contact him at his website: http://www.derekunderwood.com

Share this post
Comments (no login required)
  • Abulafio

    I already use MAMP, and I can say that it’s an amazing software, as well this is an great tutorial! Really a good job!

  • http://www.instantshift.com DKumar M.

    Nice Article.

  • Pingback: despuesdegoogle » Blog Archive » Instalar y configurar WordPress en Mac

  • http://dvnttech.com Charles rice

    I so did this a few weeks ago. wish this post would have been around then to help. but being as how easy wordpress is to install i was going the long way to china by trying to get mySQL to work with the built in php. after a few days of beating my head against that wall i went the mamp route much easier and im a lot happier now. thanks for the great read

  • http://mustardhamsters.com Dean

    I use MAMP quite frequently. Combine MAMP with Coda to edit files on your local machine and upload quickly and easily to your server. It’s really great, you get an easy way to test everything before publishing, you have a local copy of your files if anything goes wrong and you get to really use all the power of Coda.

  • http://www.derekunderwood.com Derek Underwood

    Yes, Coda is a great Mac application for working with web files. It also has a special mode for editing CSS.
    http://www.panic.com/coda/
    (I’ve completed another article for WDD about other text editing applications for Mac and Windows (and Linux) that help make designers more productive, so stay tuned!)

  • http://software-oem.com/ John Nox

    a lot of time looking for online information about discounts on software, I am very interested to read this blog, because you want to learn about all software updates! thanks

  • http://bertboan.com 13blue

    What do I do when I get finished on the local machine? How do I get everything to the production host?

  • http://www.derekunderwood.com Derek Underwood

    A comment was posted by 13blue asking about the next step – i.e. what to do when you are ready to make your development live and move it off your local machine? There are a few different ways to do this and details would best be left for another article. However, a summary would be:

    1. use the “export” function of phpMyAdmin to save the WordPress database you created

    2. copy everything from your local machine to your production server (in other words, do not bother installing WordPress from scratch onto the production server first)

    3. install phpMyAdmin to your production server if it is not already installed

    4. on your production server, use the “import” function of phpMyAdmin to recover the WordPress database you created on your local machine

    5. on your production server, use phpMyAdmin to change the WordPress database username and password

    6. on your production server, open the WordPress file “wp-config.php” and change the username and password per #5 above (or do this locally first, and then simply upload)

    7. assuming you have proper user rights set for all your directories on the production server, you should be good to go!

  • http://blog.insicdesigns.com/ insic

    Nice article.

  • Pingback: derekunderwood.com » Blog Archive » New Article at Web Designer Depot

  • http://www.themojave.com Vance Dubberly

    Why in gods name does MAMP exist? If you can’t install MySQL ( which is just a pkg ) and stop and start Apache ( which already exists on your computer ) you should be forced to ftp every little change you make to a server until you grow 2 brain cells. My god, this isn’t windows people. It’s easy, powerful, and open, at least put in a little effort.

  • http://www.derekunderwood.com Derek Underwood

    Sure, you can configure Apache, PHP and install MySQL manually on Mac OS X. Perhaps installing from source code (and compiling everything first) is the way to go if you want to learn more about OS X internals, BSD Unix, and systems administration.

    However, designers might find it productive to focus more time on creating and less time on system configuration – especially if their work is ultimately going to be hosted on another server anyways.

    Apple makes heavy use of open source technologies in OS X, including Apache, PHP and SQLlite. MAMP exists so that you can lock down your PHP/Apache/MySQL development environment without worrying about changes made by Apple’s Software Update. MAMP also allows you to tweak and experiment with PHP/Apache/MySQL settings without upsetting OS X’s configuration of its version of those same applications.

    You are right – Mac is not Windows, but that does not mean that designers using Windows are inferior. In fact until OS X, I would venture to say that Windows was superior in most every way. Even today, Windows users enjoy a much greater stable of software and accessories to choose from. Quark and Adobe makes software for both Mac and Windows – guess which sells more? As far as Windows, similar installs also exist to quickly deploy Apache/PHP/MySQL on Windows. You can search on the internet for “WAMP”. The same goes for Linux – search for “LAMP”.

  • http://kodotrade.com KodoTrade

    This is yet another great aritcle…
    really appriciate posting this.

    Next step is the visitors.
    So are currently studying ALOT of Seo ;)

    Thx again :D

  • http://www.gavalian.com Gavalian Web Design Studio

    Great Article, Thanks. :)

  • http://vizou.com Vizou

    Fantastically well done article; I use this setup myself. I’d add that designers using Coda might also enjoy CSSEdit which has a much better interface for editing CSS; I am hoping that Coda (which I also depend upon) will replicate some of CSSEdit’s great features… http://macrabbit.com

    In response to Mr. Dubberly, Apple’s version of Apache and MySQL have “default path” issues that make the MAMP setup much easier to start in for not-completely-geeks; at least they did in Tiger; now I’m in Leopard and having already done an install of MAMP, haven’t checked to see if they fixed this problem.

  • Orange7

    Great article! Very easy to follow- happy to say it’s up and running now on my mac!!

  • http://www.freshinput.com jay

    Thought you should note the link in your article in step 6 should be .org not .com http://wordpress.org/latest.zip.

  • http://www.webdesignerdepot.com Walter

    Thanks Jay for pointing that out – problem fixed.

    Regards,

    Walter

  • http://www.jauhari.net/ Jauhari

    For me, it’s more better using MacPorts ;)

  • http://www.derekunderwood.com Derek Underwood

    MacPorts is fantastic and provides many open source projects ready to compile and install for Mac OS X. Thanks for mentioning it!

    However, designers without command line experience or Xcode experience may find it time consuming for setting up a basic web development environment. With MAMP, designers can switch between PHP 4 and 5 instantly (to better match their production server) and easily make a number of configuration changes to Apache, PHP and MySQL if necessary. If something goes wrong, MAMP resides in the Applications folder and can simply go to the Trash and be installed again.

  • Pingback: firm-tofu served daily » Quick and Easy WordPress Development on a Mac with MAMP | Webdesigner Depot

  • http://www.gamesnooper.com JustChris

    I’ve used this tool for weeks now and it’s a piece of cake to configure. Once running, it’s practically invisible. Too bad I would still have to learn to set up MySQL manually if I ever need to learn Ruby.

  • http://www.derekunderwood.com Derek Underwood

    Ruby is a general programming language that is available for many operating systems. Ruby on Rails (RoR) is a Ruby framework that provides web-specific Ruby routines to assist developers in rapidly building high-quality web applications. I encourage everyone to check out Ruby and RoR. Similar to PHP, ASP, and ColdFusion, RoR can act like a scripting language that runs on the web server.

    Yes, Ruby on Rails (RoR) can work with MAMP. There are projects like “Locomotive” and others to quickly install RoR on your Mac. Meanwhile, you can continue to use the versions of Apache and MySQL that MAMP installs for you. In addition, you can continue to use MAMP’s installation of PHPMyAdmin to administer and tweak your database in conjunction with RoR.

    I don’t know if I would agree that you need to learn to use MySQL manually (from the command line) in order to learn Ruby or RoR. One of the great things about RoR is that it actually does a lot of the database work for you and gives you a chance to focus on the bigger aspects of your web application projects. Maybe a good topic for another MDN article?

  • AudioVoyeur

    WOW Great Post!

    Thank you so much! Really Great tutorial for noobs (like me)!

    Thank you for taking the time!

    Kind Regards

  • PlastisCS

    awesome guide – that you! worked perfectly
    i knew there must be an easy eay to do all this!
    cheers :)

  • Gene R.

    great help thank you for posting this

  • http://www.sgi.com Marlow Quest

    really easy to follow and I had it all set in maybe 20 min
    thanks for instructions

  • connie

    it is a great article, but when i click the index super-blog folder, it said “Error establishing a database connection”, does anyone can help me out? many thanks

  • http://www.derekunderwood.com Derek Underwood

    * Connie

    Thanks for your comment.

    Sounds like you are getting a WordPress error that it can not access the database.

    Perhaps you have a mismatch between step #4 and step #7 above.

    In step #4, double check the name of the database that you created in PHPMyAdmin and make note of it.

    Then in step #7, double check your “wp-config.php” file. Make sure that DB_NAME is set to be the same name that you gave your database in step #4. If the names you set in #4 and #7 do not match, then WordPress will not be able to access the database. Also, make sure the DB_USER and DB_PASSWORD are those that you set in #4 (if you changed them). By default, MAMP sets both the MySQL database user and password to “root”.

    Hope that helps.

    Also, for those that misunderstood me, “superblog” and any database names or other names in the tutorial are just examples. You can name your website, blog, database, any names you wish and they do not have to match each other.

  • http://www.stewartdesign.com Amy Stewart

    Thank you so much for this excellent tutorial! I was able to set it all up successfully, but now I can’t log into the wp-login page. I have no idea what to use for my WordPress user name and password. Any ideas?

  • http://www.stewartdesign.com Amy Stewart

    Okay, never mind. I must’ve breezed past the page the first time around that had my user name and password. Thanks!

  • Pingback: Webdesigner Depot: Great Resource for Web Designers

  • Anita

    Hi,

    Thanks for that article. I’ve seen and read all of the MAMP / WordPress tutorials, and also the MAMP / Dreamweaver one. No one has been able to tell me if:
    The local host and the remote host are the same, wouldn’t I define remote as “none”, since it’s already defined in the local?

    My info is:

    **Local Info window:**
    Local Root folder: Macintosh HD:Applications:MAMP:htdocs: (do i leave off :wordpress?)
    http address: http://localhost:8888/wordpress/
    Link relative to document? or does it matter?

    **Remote Info window:**
    Access: Local/Network
    Remote folder: Macintosh HD:Applications:MAMP:htdocs:
    or is remote all “None” because it’s the same location as local?

    Testing Server is PHP…Local Area Network, Folder: Macintosh HD:Applications:MAMP:htdocs:
    URL Prefix is http://localhost:8888/wordpress/

    I have searched and searched online for info, but none was specific to this, thanks!

  • Minnie

    GREAT article. Thanks a million!

  • jennifer Menke

    after spending most of the following instructions for doing this with the ports set at 8888 and 8889 and failing. I finally was able to install wordpress locally. then was presented with a log in screen and I can’t figure out what should go into username and password. Is it the name of the database? is password root? I clicked on “forgot password” and never got an email! so frustrated! any advice?

  • http://colombelesvesoul.fr jpg001

    hi, from France

    i use wordpresss 2.7.1 with mamp (php5, ports 80 and 3306)

    it’s ok, but i don’t see the little number when there is an update for a plugin and also the message under the plugin in the format list.

    But, i try One Click Plugin Updater plugin and now i see the little number and the message !!

    an other widget problem with forecast weather, i see the weather information sometimes. Perhaps it’s the same problem ? to receive informations from internet

    i would like to know why ?

    thank you

  • http://teographics.com Teodoro Lopez

    thank you, i just discovered this article and its great!

  • Rhobust

    Fantastic tutorial – I was able to install MAMP without a hitch

    Many thanks

  • http://www.flort.net/modules.php?name=Download Arkadaslik Muhabbet Sohbet

    Great Article, Thanks. :)

  • Justyn McKay

    Hi,
    Awesome instructions… but, can’t get past step 4:

    Safari can’t connect to the server.
    Safari can’t open the page “http://localhost:80/MAMP/?language=English” because it could not connect to the server “localhost”.

    Have been trying so hard to access wordpress on my mac and would really love to succeed.
    Feeling very hopeful that you might be able to help me. Could you?
    Might my location have something to do with the problem? (I’m in New Zealand).

    Cheers,
    Justyn

  • Bee

    I loved your website tutorial. It solved the problem I was struggling with!!

  • Mark

    I did this and everything was great until step 8. I tried to take a test drive and I could see other files in the folder but when I go to the folder with wordpress I get a text error in my browser saying “Error establishing a database connection.” Any help would be greatly appreciated.

  • http://www.subcorpus.net/blog/ subcorpus

    very informative article …
    will try this now …
    thanks …

  • http://www.trademic.com/MAC_1__.htm mac wholesale

    Thank you for sharing.. I will be downloading this cool plug in.. sure it will be usefull for my sites..
    Thanks!

  • http://martinconnelly.com Martin

    Thanks for the great walkthrough. I’ve got it working setting up a fresh install, but I’m trying to create a development environment for a live site. I’ve got the tables in the right place, and the _siteurl pointing to the right place, but I just get a blank screen. Any ideas?
    Thanks a bunch,
    Martin

  • rjreynolds

    Really cool tutorial man!! I am up and running without a hitch. Just one important thing for those of you trying to set this up. Make sure that you have no spaces in the name of the folder that you are using to keep all the wordpress files in, or your browser will not be able to find the link to your page. great job!

  • http://www.parentalcontrolapps.com monitoring software

    fantastic tutorial. Thank you very much for making this free for us to use..

  • mahasvin

    WHile MAMP/WP runs locally – its ok. When you point to machine from another host on local network I only see skeleton page in WP, no formatting at all. Looks like PHP output somehow does not reach the client browser. I am really stuck. How can I view local WP from another machine on LAN?

    • pyemachine

      If you change the localhost address to an IP address in the settings, other networked machines should see it, however tread carefully as it can confuse the wordpress install.

  • pyemachine

    Would love to see a follow up article on shifting a local MAMP wordpress install to a live website / host.

  • Kazuo

    Hi,

    I followed this tutorial to set up a localhost with MAMP but I’m having trouble editing the .php file for WordPress (I’m trying to create a theme). I’ve tried both Coda and Dreamweaver CS4 to do this but the files are all locked and displays the files as “read-only.”

    I’m guessing it’s a problem with my MAMP. I believe I granted all access to myself as it is indicated in the “Priveleges”

    Any tips? I’ve been running in circles searching for this on the web. =/

    Best regards!

  • http://www.massivemouse.com Scott Semple

    Why change the ports from default (8888 & 8889) to 80 and 3306?

  • Derek Underwood

    You can leave the ports at 8888 and 8889. However, if you make them the real web and MySQL ports (80 and 3306) it can smooth your transition to a live site. Plus, while developing you don’t have to append your URLS with :8888 in the meantime.

    It is also important to make sure that Apache that comes with the Mac is not running and wrestling with the Apache launched my MAMP. That is why I suggest turning off web sharing and then setting MAMP to use port 80 for Apache. That way, there can be no confusion as to which Apache is active, etc. during development.

    These are just guidelines. There are many ways to work with MAMP.

  • Derek Underwood

    Someone commented about moving a site from MAMP to a live site on a server.

    I’lll comment on this briefly.

    This involves backing up the database and importing it into the live database server (you can use phpmyadmin for that). Next you have to copy all your web files including the wordpress install and then copy them to your new server.

    However, that is just part of the story as the WordPress database will not likely have the correct info for your real world domain name so your site may not work properly at first. So before doing anything, try these steps:

    1. Before copying the wordpress install and all files to your server, first duplicate the entire wordpress install and set it aside for a moment – you will need it when you want to do further local development. Also, go into phpmyadmin and export/backup the wordpress database. Import it back into a new database in phpmyadmin locally for future local development.

    2. Go into your live local WordPress wp-admin and change the WordPress URL to your real domain name etc. – as soon as you change it, WordPress will no longer work on your local machine. (which is OK, since you made a duplicate as mentioned above, right?) Copy that non-working wordpress install to your new online server.

    3. You may need to tweek wp-config for your server’s database credentials, etc. online. For more local development, go into the duplicate of your local WordPress install ad tweak wp-config to use the backup of the wordpress database that you put in a new database (per #1 above). Make your local duplicate your new live wordpress for local development.

    4. Next, export/backup the new-non-working wordpress local database using phpmyadmin. (it does not work because it now has your real online URL embedded but you are working locally!)

    5. Next, open that local database backup with a text editor. You can use textview or textmate or whatever you like. Then you need to globally search and replace all instances of your local URL with the real online URL. You will notice that image URLs, for example, will be wrong otherwise although other URLs will be correct.

    6. Next, import that revised database into your new server.

    Launch WordPress on the new server.

    After doing this a few times, you will become a pro – believe me!

    More tips here straight form the horse’s mouth:
    http://codex.wordpress.org/Moving_WordPress

    Keep in mind that the wordpress database stores your URL (domain name) and also file location for all images, etc. So “localhost…” will not be correct for your live site online – that needs to be changed to “yourdomain…” That is why it is important to search are replace localhost with your domain using a text editor before importing the database into your live site.