Getting Apache, PHP and MySQL to work on Leopard

Enabling PHP

If you have upgraded from Tiger, you may need to complete this step to get Leopard’s version of Apache to work with UserDir (otherwise ignore this bit):

  • Copy your old userdir configurations from /etc/httpd/users/ to /etc/apache2/users/

PHP is normally disabled by the default Apache configuration, so you will need to load up a text editor and then:

  • Uncomment LoadModule php5_module libexec/apache2/libphp5.so in /etc/apache2/httpd.conf

Once you’ve saved this, you’ll need to restart apache. The easiest way to do this is to go to System Preferences > Sharing and to turn Web sharing off then on again.

Installing MySQL

To install MySQL, just follow these steps:

  • Download the MySQL OS X disk image from a MySQL mirror
  • Mount the image, and install the main package, the startup item package, and then the preferences pane
  • Add the mysql bin folder to your path:
    sudo echo 'export PATH=$PATH:/usr/local/mysql/bin' >> ~/.bash_profile
  • If no /private/etc/php.ini exists, make a copy of php.ini.default
  • Update php.ini to point at the new MySQL socket mysql.default_socket = /private/tmp/mysql.sock – do this for both mysql and mysqli.
    mysql.default_socket = /private/tmp/mysql.sock
    mysqli.default_socket = /private/tmp/mysql.sock

Other tips if you having problems with .htaccess

Ensure the following directives are enabled (e.g. look in /etc/apache2/users/username.conf) :

Options FollowSymLinks
AllowOverride All

2 thoughts on “Getting Apache, PHP and MySQL to work on Leopard”

Leave a Reply

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