Per Søderlind

I code for fun

  1. how-to
  2. Running WordPress locally on Mac OS X Lion, Mountain Lion and Mavericks

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:
[shell light=”true”]
$ sudo apachectl start

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

[shell light=”true”]
$ man apachectl

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:

[shell light=”true”]
sudo defaults write /System/Library/LaunchDaemons/org.apache.httpd Disabled -bool false

Create /var/mysql/mysql.sock if it doesn’t exist (or replace /var/mysql/mysql.sock with /tmp/mysql.sock further below)
[shell light=”true”]
$ sudo mkdir /var/mysql
$ sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock

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

[shell light=”true”]
$ sudo sh -c “grep php /etc/apache2/httpd.conf|grep LoadModule|cut -d’#’ -f2 > /etc/apache2/other/php5-loadmodule.conf”
$ sudo cp -a /etc/php.ini.default /etc/php.ini
$ sudo sh -c “cat >> /etc/php.ini <<‘EOF’
;; User customizations below

; Original – memory_limit = 128M
memory_limit = 196M
; Original – post_max_size = 8M
post_max_size = 200M
; Original – upload_max_filesize = 2M
upload_max_filesize = 100M
; Original – default_socket_timeout = 60
default_socket_timeout = 600
; Original – max_execution_time = 30
max_execution_time = 300
; Original – max_input_time = 60
max_input_time = 600
; Original – display_errors = Off
display_errors = on
; Original – display_startup_errors = Off
display_startup_errors = on
; Original – ;date.timezone =
date.timezone = ‘America/New_York’ // Change to your timezone:

$ sudo sh -c “cat >> /etc/php.ini <<‘EOF’
; Original – ;include_path = “.:/php/includes”
include_path = “.:/usr/lib/php/pear”

$ sudo sed -i “” ‘s#/var/mysql/mysql.sock#/tmp/mysql.sock#g’ /etc/php.ini

$ sudo apachectl restart

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:

# Use name-based virtual hosting.
NameVirtualHost *:80

# Set up permissions for VirtualHosts in ~/Sites
<Directory “/Users/<username>/Sites”>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all

# For http://localhost in the OS X default location
<VirtualHost _default_:80>
ServerName localhost
DocumentRoot /Library/WebServer/Documents

# VirtualHosts below

# wp.local
<VirtualHost *:80>
ServerName wp.local
CustomLog “/Users/<username>/Sites/logs/wp.local-access_log” combined
ErrorLog “/Users/<username>/Sites/logs/wp.local-error_log”
DocumentRoot “/Users/<username>/Sites/wordpress”

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:

$ cd /Users/<username>/Sites
$ sudo chown -R :_www wordpress
$ sudo chmod -R g+w wordpress

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

[php light=”true”]
define(‘FS_METHOD’, ‘direct’);

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:

<VirtualHost *:80>
ServerName mu.local
CustomLog “/Users/<username>/Sites/logs/mu.local-access_log” combined
ErrorLog “/Users/<username>/Sites/logs/mu.local-error_log”
DocumentRoot “/Users/<username>/Sites/mu.local”

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.


Upgraded to WordPress 3.2 and nothing worked (internal error …)


Front-end editor in WordPress 3.3 is easy


  1. bananaaus

    You legend!

  2. Jarratt

    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!

    • PerS

      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

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

      define(‘FS_METHOD’, ‘direct’);

  3. Jarratt

    Hi again,
    That’s great, all up an running now. Thanks a lot!

  4. 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?


    • PerS

      Is your .htaccess writeable by wordpress ? Mine looks like this (and permalinks works):
      # BEGIN WordPress
      <IfModule mod_rewrite.c>
      RewriteEngine On
      RewriteBase /
      RewriteRule ^index.php$ – [L]
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule . /index.php [L]

      # END WordPress

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

  6. chapman welch

    Thanks for the tip. You saved me a few hours of pain and suffering!

  7. Senica

    Thanks for posting. Was driving me crazy.

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

  9. PakPenyo

    solution for me is change both user and group:

    sudo chown -R _www:_www wordpress


    • PerS

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

  10. 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?

    • PerS

      I use when I migrate a site from localhost to production. It does the necessary changes to wp-config.php

      • 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 ;)

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

  11. 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?

    • PerS

      You must replace <username> in the examples above with your username.

      • 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)

  12. Excellent! Thanks for posting this. I was having a time with this one and this did the trick right away thanks !

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

  14. PerS

    Adian and Phil,

    Glad I could help. Please tell others using twitter etc.

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

  16. steve

    It should be possible to install plugins locally by only changing the the group to _www for wp-content and adding write permissions to group, then adding the define(‘FS_METHOD’, ‘direct’); line to your wp-config.

  17. Jarod Taylor

    After changing the permissions it rendered my localhost/~username directory 404 Page not found.

  18. Thanks very much :)

Leave a Reply

Powered by WordPress & Theme by Anders Norén