K.R.C. LogoThe Book of Kara

Soup-to-nuts Wordpress, PHP5 and MySQL on Mac OS X Leopard

Published 11 November 2007

Hi! You've stumbled upon a blog post by a guy named Ryan. I'm not that guy anymore, but I've left his posts around because cool URIs don't change and to remind me how much I've learned and grown over time.

Ryan was a well-meaning but naïve and priviledged person. His views don't necessarily represent the views of anyone.

I less-than three Mac OS X Leopard so far, but I ran into a number of issues when I tried to do my first Web development project. It had been so long since I first dug into the Tiger terminal and got everything rolling that I had to re-figure it all out on Leopard--with a few added quirks. Here are my steps; your milage my vary.

1. Install MySQL

MySQL isn't installed by default, so I went to the MySQL web site to download MySQL 5.0 for OS X. I just use the binary package, and installed the prefpane as well (silly me).

2. Start MySQL

Unfortunately, the MySQL prefpane doesn't exactly work in Leopard. I had to look up how to start MySQL from the terminal. It's a simple:

ryan$ sudo /usr/local/mysql/bin/safe_mysqld

It looks like MySQL's socket file exists in a different place than most applications expect. One workaround just symbolically links the previous location to the current one. I'm no expert, so that might be a bad idea.

3. Enable PHP

The initial configuration of Apache 2 does not enable PHP by default. Luckily, Tyler knows how to enable PHP5 in Leopard: in the apache configuration file, /private/etc/apache2/httpd.conf, uncomment the line

LoadModule php5_module     libexec/apache2/libphp5.so

4. Change default MySQL socket

If you haven't used Angry Fly's workaround mentioned above, you have to change PHP's default MySQL socket to it's actual value. Do this by changing the line in /private/etc/php.ini to

mysqli.default_socket = /tmp/mysql.sock

5. Enable .htaccess

Finally, you have to enable .htaccess files again. The instructions for Tiger work fine, except that Apache's configuration file is no longer in /etc/httpd, it's in /private/etc/apache2.

6. Modify the default Wordpress htaccess file

Everything was going swimmingly until I tried to enable friendly URLs in WordPress 2.3.1. I'm still not sure why this is an issue, but I was getting 403 Forbidden errors after Wordpress created a .htaccess file. This page provided me the (somewhat spookey) answer.

And amazingly, I was rolling. Well, I will be rolling, as this information seeking exercise and the requisite blog post have now kept me up far past my goal turn-in time.

K.R.C. LogoPrevious: Trouble—right here in Culver CityNext: E-mail, Spam and The Magic Plus