I’ve recently gotten my hands on a new-ish iMac with a freshly installed copy of Lion (as opposed to my 6+ year old macbook which has seen so many versions of the kitty branded OS, it now LoLz all the time) and found that setting up a local WordPress Multisite dev environment to be somewhat tricky.
Out of the box, Lion comes with all the goodies you need to run a php/MySQL project, but nothing is ever in the right place.
Case in point, enabling apache is as simple as going to System Preferences > Sharing > Web Sharing, and Boom, you have a local web server running. Just go to http://localhost/ and you should see the traditional apache “It Works!” message.
A simple change to your http.conf is all you need to get PHP set up, provided you can find it. Any Apache guru will tell you it varies from system to system, and OSX lion is no exception.
After setting that part up, I had many issues with permissions, but this may not affect you, as I was working in a high security environment, and the image was totally locked down. You don’t want to know what I had to do to get local admin rights.
Once I had apache and php set up, MySQL was pretty straight forward. Just go to MySQL’s download page and get the DMG. Setting up was a breeze, so I should have realized something went wrong.
I went ahead to start the WordPress 5 Minute Install and got stuck on the config.
No matter what I did, I kept getting this odd error message in my log files:
“Error establishing a database connection”
Can’t connect to local MySQL server through socket ‘/var/mysql/mysql.sock
I searched the interwebs for various articles, thankful I wasn’t the only one to get caught up by this issue. The good folks over at foolswisdom.com had a really good article about this database connection issue.
In short, the php.ini file was looking for mysql.sock in /var/mysql/mysql.sock, but the file itself was installed under /tmp/mysql.sock
A quick change to the php.ini file and I was all set.