Want 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
|
1 |
$ sudo apachectl start |
apachectl main commands are: start, stop and restart. You can learn more about apachectl by entering the following in Terminal
|
1 |
$ 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:
|
1 |
sudo defaults write /System/Library/LaunchDaemons/org.apache.httpd Disabled -bool false |
Also, If you followed the instructions below earlier and upgraded your Lion to Mountain Lion, you’ll have to reenable PHP:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
$ 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' EOF $ sudo sh -c "cat >> /etc/php.ini <<'EOF' ; Original - ;include_path = ".:/php/includes" include_path = ".:/usr/lib/php/pear" EOF $ 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:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# # 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 </Directory> # For http://localhost in the OS X default location <VirtualHost _default_:80> ServerName localhost DocumentRoot /Library/WebServer/Documents </VirtualHost> # # 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" </VirtualHost> |
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:
|
1 2 3 |
$ 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:
|
1 |
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:
|
1 2 3 4 5 6 |
<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" </VirtualHost> |
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.
Pingback: WP FTP frissítés OSX Lion alatt | Feljegyzések
Pingback: Running WordPress Multisite with MAMP « Socializing the Network
You legend!
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
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:
Hi again,
That’s great, all up an running now. Thanks a lot!
Pingback: MAMP + Mac Lion + WordPress + FTP + auto update: The ultimate (?) solution | GlückPress
Pingback: MAMP + Mac Lion + WordPress + FTP + automatisches Update: Die ultimative (?) Lösung | GlückPress
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!
Is your .htaccess writeable by wordpress ? Mine looks like this (and permalinks works):
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
Anonymous haters suck. If you’re gripe matters enough to leave as a comment, at least show yourself.
Thanks for the tip. You saved me a few hours of pain and suffering!
Thanks for posting. Was driving me crazy.
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.
solution for me is change both user and group:
sudo chown -R _www:_www wordpress
thanks.
That’s fine, as long as you are member of the group _www, otherwise you (as in your user) can’t edit the files.
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?
I use http://ithemes.com/purchase/backupbuddy/ when I migrate a site from localhost to production. It does the necessary changes to wp-config.php
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..
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?
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)
Cheers!
Excellent! Thanks for posting this. I was having a time with this one and this did the trick right away thanks !
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.
Adian and Phil,
Glad I could help. Please tell others using twitter etc.
Pingback: Auto update for local Wordpress on Mountain Lion - stuph...
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
This usually means that the plugin archive couldn’t be extracted because of too little disk space, but it might also be because this: http://core.trac.wordpress.org/ticket/22913
Thanks for your reply, it’s format problem. I upload a zip file, and it’s working now.