Snow Leopard PHP Extensions Installation Tutorial

By Xeon Xai  

This will help you to setup imagick, magicwand, xdebug, mcrypt and memcached for Snow Leopard’s bundled PHP 5.3.0. Please do expect the installation of ImageMagick to take a bit of time, as it requires a large number of packages. I’m doing it all my preferred way. If you have another way that is faster or better, I’d be glad to take your suggestions and make this tutorial more streamlined.

Step 1:

Make sure you have XCode 3.2 for Snow Leopard installed, from the Snow Leopard install DVD.

Step 2:

Download MacPorts for Mac OS X 10.6 Snow Leopard here.

If you have previously installed MacPorts and installed software with it in Mac OS X 10.5, run this first to remove it, as it won’t work in Snow Leopard anymore.

In Terminal:

sudo rm -rf /opt/local \
/Applications/MacPorts \
/Applications/DarwinPorts \
/Library/Tcl/macports1.0 \
/Library/Tcl/darwinports1.0 \
/Library/LaunchDaemons/org.macports.* \
/Library/StartupItems/DarwinPortsStartup \
/Library/Receipts/MacPorts*.pkg \
/Library/Receipts/DarwinPorts*.pkg \
~/.macports

Step 3:

Open the MacPorts-1.8.0-10.6-SnowLeopard.dmg file, and install the MacPorts package file.

Step 4:

To hide the /opt folder from Finder view that is visible after installing MacPorts.

In Terminal:

sudo chflags hidden /opt

Step 5:

By default, MacPorts for Snow Leopard should use x86_64 arch instead of ppc/i386, so you shouldn’t have to worry much here.

This part most likely will take the longest of all things in the tutorial, as it requires a large group of individual packages. You can cook dinner, eat it, and you might still be waiting for this to complete after you’ve finished eating. It took about a half hour for it to complete on my MacBook.

In Terminal:

sudo port install imagemagick

Step 6:

Download imagick here.

Unpack the file imagick-2.3.0.tgz.

In Terminal:

cd ~/Downloads/imagick-2.3.0/imagick-2.3.0
phpize
./configure --with-imagick=/opt/local
make
cd modules
sudo cp imagick.so /usr/lib/php/extensions/no-debug-non-zts-20090626/

Step 7:

Download magickwand here.

Unpack the file MagickWandForPHP-1.0.8.tar.gz.

In Terminal:

cd ~/Downloads/MagickWandForPHP-1.0.8/
phpize
./configure --with-magickwand=/opt/local
make
cd modules
sudo cp magickwand.so /usr/lib/php/extensions/no-debug-non-zts-20090626/

Step 8:

Download xdebug here.

Unpack the file xdebug-2.0.5.tgz.

In Terminal:

cd ~/Downloads/xdebug-2.0.5/xdebug-2.0.5
phpize
./configure
make
cd modules
sudo cp xdebug.so /usr/lib/php/extensions/no-debug-non-zts-20090626/

Step 9:

In Terminal:

sudo port install libmemcached

When it completes, type this into Terminal:

sudo launchctl load -w /Library/LaunchDaemons/org.macports.memcached.plist

Step 10:

Download memcached here.

Unpack the file memcached-1.0.0.tgz.

In Terminal:

cd ~/Downloads/memcached-1.0.0/memcached-1.0.0/
phpize
./configure --with-libmemcached-dir=/opt/local
make
cd modules
sudo cp memcached.so /usr/lib/php/extensions/no-debug-non-zts-20090626/

Step 11:

Download libmcrypt here.

Unpack the file libmcrypt-2.5.8.tar.bz2.

In Terminal:

cd ~/Downloads/libmcrypt-2.5.8/
./configure --disable-posix-threads --enable-static
make
sudo make install

Step 12:

Download PHP 5.3.0 source code for the mcrypt extension here.

Unpack the file php-5.3.0.tar.gz. We will only need to use the code within the ext/mcrypt directory. No need to compile all of PHP for this.

In Terminal:

cd ~/Downloads/php-5.3.0/ext/mcrypt
phpize
./configure
make
cd modules
sudo cp mcrypt.so /usr/lib/php/extensions/no-debug-non-zts-20090626/

Step 13:

In Terminal:

cd /etc
sudo cp php.ini.default php.ini
sudo pico php.ini

Search for:

display_errors

Set this to:

display_errors = On

Search for:

html_errors

Set this to:

html_errors = On

I placed the following after all the commented out lines for extensions:

;;;;;;
extension=/usr/lib/php/extensions/no-debug-non-zts-20090626/mcrypt.so
extension=/usr/lib/php/extensions/no-debug-non-zts-20090626/magickwand.so
extension=/usr/lib/php/extensions/no-debug-non-zts-20090626/imagick.so
extension=/usr/lib/php/extensions/no-debug-non-zts-20090626/memcached.so
zend_extension=/usr/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so
xdebug.default_enable = On
xdebug.collect_params = 4
xdebug.trace_format = 1
xdebug.show_local_vars = On
xdebug.dump_globals = On
xdebug.show_exception_trace = On
xdebug.collect_assignments = 1
;;;;;;

Set your default timezone. I’ll show mine as an example.

date.timezone = America/New_York

Set your mysql default port.

mysql.default_port = 3306

Press Control-X to exit, it will ask if you want to save changes, so press Y for Yes, and press Enter save and exit completely.

Step 14:

Restart Apache.

In Terminal:

sudo apachectl graceful

That should do it, as this is the exact steps I took to install all of these just now. And everything worked for me just as typed.

Hope this helps you out.

Enjoy.

VN:F [1.9.22_1171]
Rating: 9.7/10 (24 votes cast)
VN:F [1.9.22_1171]
Rating: +12 (from 16 votes)
Snow Leopard PHP Extensions Installation Tutorial, 9.7 out of 10 based on 24 ratings

62 Comments

12 Trackbacks

Post a Comment

Your email is never shared. Required fields are marked *

*
*