Friday, July 10, 2009

php 5.3.0 + mysql + pdo_mysql on leopard

Thanks to Wieden+Kennedy for indirectly sponsoring this post!

This is a brief explanation of how you might be able to get pdo_mysql working on Leopard (OS X 10.5.6 and 10.5.7) with the stock Apache installation, on an Intel-based Mac, while conveniently updating PHP as well. I was able to scrape this together from a few blog posts, mostly this one, and also some guess work.

You need to know what kind of processor you have in your Mac. To find out, go to "About This Mac" in the Apple menu.

Instructions for Intel Core 2 Duo (64-bit)

1. Make a backup copy of this file: /usr/libexec/apache2/libphp5.so

2. Download and install the x86_64 Mac package of MySQL from the MySQL website. If you already have MySQL installed you can safely skip this step.

3. Download and unzip the PHP 5.3.0 source code from the PHP website.

4. Open a terminal window and move to the unzipped directory, then execute the following commands.

MACOSX_DEPLOYMENT_TARGET=10.5 \
CFLAGS='-O2 -arch x86_64' \
LDFLAGS='-O2 -arch x86_64' \
CXXFLAGS='-O2 -arch x86_64' \
./configure '--prefix=/usr/local/php-5.3.0' \
'--with-apxs2=/usr/sbin/apxs' \
'--with-ldap=/usr' \
'--with-kerberos=/usr' \
'--enable-cli' \
'--with-zlib-dir=/usr' \
'--enable-exif' \
'--enable-ftp' \
'--enable-mbstring' \
'--enable-mbregex' \
'--enable-sockets' \
'--with-iodbc=/usr' \
'--with-curl=/usr' \
'--with-config-file-path=/etc' \
'--sysconfdir=/private/etc' \
'--with-mysql-sock=/var/mysql' \
'--with-mysqli=/usr/local/mysql/bin/mysql_config' \
'--with-mysql=/usr/local/mysql' \
'--with-openssl' '--with-xmlrpc' \
'--with-xsl=/usr' \
'--without-pear' \
'--enable-pdo=static' \
'--with-pdo-mysql=/usr/local/mysql'


make
sudo make install
sudo apachectl restart

See below for instructions on how to finalize and test.

Instructions for Intel Core Duo (32-bit)

1. Make a backup copy of this file: /usr/libexec/apache2/libphp5.so

2. Download and install the x86 (not x86_64) Mac package of MySQL from the MySQL website. If you already have MySQL installed you can safely skip this step.

3. Download and unzip the PHP 5.3.0 source code from the PHP website.

4. Open a terminal window and move to the unzipped directory, then execute the following commands.

MACOSX_DEPLOYMENT_TARGET=10.5 \
CFLAGS='-O2 -arch i386' \
LDFLAGS='-O2 -arch i386' \
CXXFLAGS='-O2 -arch i386' \
./configure '--prefix=/usr/local/php-5.3.0' \
'--with-apxs2=/usr/sbin/apxs' \
'--with-ldap=/usr' \
'--with-kerberos=/usr' \
'--enable-cli' \
'--with-zlib-dir=/usr' \
'--enable-exif' \
'--enable-ftp' \
'--enable-mbstring' \
'--enable-mbregex' \
'--enable-sockets' \
'--with-iodbc=/usr' \
'--with-curl=/usr' \
'--with-config-file-path=/etc' \
'--sysconfdir=/private/etc' \
'--with-mysql-sock=/var/mysql' \
'--with-mysqli=/usr/local/mysql/bin/mysql_config' \
'--with-mysql=/usr/local/mysql' \
'--with-openssl' '--with-xmlrpc' \
'--with-xsl=/usr' \
'--without-pear' \
'--enable-pdo=static' \
'--with-pdo-mysql=/usr/local/mysql'


make
sudo make install
sudo apachectl restart

Finishing up on ALL platforms

Take a look at your phpinfo(), and if all went well, you will see MySQL listed in the drivers under PDO. If it doesn't work, the bailout is to put the original libphp5.so back into place... you know, the one you backed up in step 1... you did back it up, right?

If you want to use the command-line executables, I recommend adding /usr/local/php-5.3.0/bin to your PATH environment variable before /usr/bin.

PHP CLI users: If you are getting this warning:
PHP Warning: PHP Startup: Unable to load dynamic library './pdo_mysql.so' - (null) in Unknown on line 0

Comment out the following line in /etc/php.ini:
extension=pdo_mysql.so

1 comment:

Anonymous said...

Casino Slot Machines - Tricktactoe
When you play a Slot machine online 메이저놀이터 at one of the casinos at the top of the page, you'll see all the games including mib사이트 a 스포츠토토 최고배당 샤오미 bonus round, a 스포츠 토토 결과 free spins 토토사이트 승률 높이는 법 벳무브 and