Running WordPress locally on Mac OS X Lion, Mountain Lion and Mavericks

Apple and WordPressWant to run WordPress on OSX? I’ve wanted to do it for a long time and finally got a round to do it.

Multisite: See notes below if you plan to run a Network of WordPress (aka multisite) on your Mac.

New: Here’s an alternative, take a look at WordPress on Pow (includes a “how-to add MySQL, PHP5.4.9 and Ruby 1.9.3“)


Update: Mountain Lion and Mavericks

Web Sharing in Mountain Lion is removed from System Preferences->Sharing (no idea why), so to start the web server, open Terminal (or iTerm) and enter:
 

apachectl main commands are: start, stop and restart. You can learn more about apachectl by entering the following in Terminal

apachectl is sufficient when you need to start, restart or stop the server while testing, but if you want the web server to start automatically after a reboot, you’ll have to enable the launch daemon for the server:

Create /var/mysql/mysql.sock if it doesn’t exist (or replace /var/mysql/mysql.sock with /tmp/mysql.sock further below)

Also, If you followed the instructions below earlier and upgraded your Lion to Mountain Lion, you’ll have to reenable PHP:

How I installed MAMP + WordPress

1 ) Installed Apache, MySQL and PHP on my Mac. I followed this excellent guide: OS X 10.7 Lion Development: Native MAMP with MySQL installer. Here’s the /Users/<username>/Sites/httpd-vhosts.conf I made:

2) Installed WordPress in /Users/<username>/Sites/wordpress

When I tried to install the first plugin, I got the dreaded FTP Connection Information required :/

Luckily, Google to the rescue, I found this fix to allow WordPress automatic plugin installation/update:

A) Changed the owner and permissions for the entire WordPress installation, assuming you installed WordPress in /Users/<username>/Sites:

B) Added the following to /Users/<username>/Sites/wordpress/wp-config.php:


How to create a WordPress multisite locally

1) Follow the instructions above, and create a separate database per multisite

Easiest is to create a path-based (that is use sub-directories) multisite. My multisite virtual host looks like this:

2) When WordPress is up and running, follow steps 2 – 6 in the Create a Network guide.

If you have any questions, please don’t hesitate to ask below. I’ll try to answer as soon as possible.

31 thoughts on “Running WordPress locally on Mac OS X Lion, Mountain Lion and Mavericks

  1. Pingback: WP FTP frissítés OSX Lion alatt | Feljegyzések

  2. Pingback: Running WordPress Multisite with MAMP « Socializing the Network

  3. Jarratt

    Hello,
    I’m just setting up a local installation of WordPress on my Mac with OSX Lion. I’ve managed to install it but I can’t update any plugins, import my blog etc (I’m new to all this so flying blind so to speak).

    I have read something about changing my FTP permissions? I don’t really understand what the article above is saying, could you please give some further info for me?

    Thanks a lot, hopefully you can help!
    Jarratt

    Reply
    1. PerS Post author

      You have to do the following:

      A) Changed the owner and permissions for the entire WordPress installation, assuming you installed WordPress in /Users/<username>/Sites:

      [code lang="shell" light="false"]
      $ cd /Users/<username>/Sites
      $ sudo chown -R :_www wordpress
      $ sudo chmod -R g+w wordpress
      [/code]

      B) Added the following to /Users/<username>/Sites/wordpress/wp-config.php:

      Reply
  4. Pingback: MAMP + Mac Lion + WordPress + FTP + auto update: The ultimate (?) solution | GlückPress

  5. Pingback: MAMP + Mac Lion + WordPress + FTP + automatisches Update: Die ultimative (?) Lösung | GlückPress

  6. Nick

    So I am having a problem with permalinks after setting up my dev environment on OSX Lion. I have AllowOveride All in my httpd.conf and in my vhosts file as you show, mod_rewrite is enabled… Any ideas?

    Thanks!

    Reply
    1. PerS Post author

      Is your .htaccess writeable by wordpress ? Mine looks like this (and permalinks works):

      Reply
  7. blah blah

    seems like alot of trouble to me,

    i use mamp pro & coda,

    std mamp install and wordpress into a wordpress directory in the sites folder,no need for all that messing around for the same result, oh and everything works like its on a live server, mail,permalinks,updates for wordpress & plugins, .htaccess writeable etc etc

    Reply
  8. Martyn Chamberlin

    This is absolutely awesome! I’ve been having to manually install/update WordPress, my framework, and my plugins. Thanks to this tutorial, this evil hassle has been reduced to a few simple clicks.

    Reply
    1. PerS Post author

      That’s fine, as long as you are member of the group _www, otherwise you (as in your user) can’t edit the files.

      Reply
  9. Yanns

    thank you very much, however there is a question.. should I care for anything when I migrate the local site to public? Should I remove the last like from wp-config.php?

    Reply
      1. Yanns

        yes but do you think making changes to wp-config.php is enough? I haven’t done it before on WP but I think we need to fix other things as well before it go live. Such as links etc..
        maybe my question was silly but ok, I will get the grip of it a day ;)

        Reply
      2. Yanns

        ..and does the backupbuddy take care of the access rights we gave with the commands above? I mean to make them back to normal. I wouldn’t want have any problem with access rights when the website is online..

        Reply
  10. Yanns

    in my command line (lion) it says:
    -bash: Users//Site/lookup/folders: No such file or directory

    the path is just an example. I tried to find where the path breaks, trying the command $cd in small chunks but there’s again the same issue.
    what should i do?

    Reply
      1. Yanns

        Yeah, I had done that. what I did was to illustrate you the path.

        Finally, the problem was caused by a silly thing I had done: I had put spaces in the filenames so the terminal couldn’t find the folder..

        Another problem was that I wasn’t writing the correct filepath. so I looked it up and I found that you can write the first 1-2 letters of your filename and then press Ctrl+tab (for mac it is the same, ex.Ctrl+tab, and command+tab won’t work). After you do it, the terminal will write the filename for you!..

        Last, another problem was that I was writing ..sudo chown -R:_www wordpress
        My mistake:
        I had to write the parent folder name of the file.. I thought that wordpress was part of the command. So the correct one is:

        sudo chown -R:_www exampleFilename
        (ofcourse same goes for chmod)
        Cheers!

        Reply
  11. Phil

    Installed WP but had probs when uploading media due to permissions problems. Hunted for ages to find a solution. Your site sorted it immediately. Cheers.

    Reply
  12. Pingback: Auto update for local Wordpress on Mountain Lion - stuph...

  13. Babass

    Hello,
    i have an error during plugin installation. Before folder access denied problem, i have new error message :
    “The package could not be installed. PCLZIP_ERR_BAD_FORMAT (-10) : Unable to find End of Central Dir Record signature”
    What does it mean ?
    thanks for help

    Reply

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">