Extensions

Snow Leopard PHP and IMAP Support

Seeing as how the stock Apple Mac OS X 10.6 Snow Leopard PHP 5.3 doesn’t come with IMAP extension support, I realized it was time to add it in to build a tool to extract data from my gmail account emails. Here is the steps I took to get it installed and working.

Step 1:

Download IMAP source code. (2007e as of writing this). Without this, trying to compile the IMAP PHP extension will give you errors and will refuse to compile.

Unpack the imap-2007e.tar.gz file.

In Terminal:

sudo mv ~/Downloads/imap-2007e /usr/local/imap-2007
cd /usr/local/imap-2007
make osx
sudo cp c-client/c-client.a c-client/libc-client.a

Step 2:

Download PHP 5.3.0 source code for the php imap extension here. I already had a copy from my previous extension tutorial, so I just used that copy.

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

In Terminal:

cd ~/Downloads/php-5.3.0/ext/imap
phpize
./configure --with-imap==/usr/local/imap-2007 --with-kerberos --with-imap-ssl
make
sudo cp modules/imap.so /usr/lib/php/extensions/no-debug-non-zts-20090626/

Step 3:

Add in the extension location to the php.ini file.

In Terminal:

sudo pico /etc/php.ini

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

extension=/usr/lib/php/extensions/no-debug-non-zts-20090626/imap.so

After you have placed that line in there, press Control-X to exit and save.

Step 4:

Restart Apache.

In Terminal:

sudo apachectl graceful

Now you should be able to see the imap extension installed in your stock Apple PHP.

VN:F [1.9.3_1094]
Rating: 10.0/10 (1 vote cast)
VN:F [1.9.3_1094]
Rating: -1 (from 1 vote)

Snow Leopard PHP Extensions Installation Tutorial

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.3_1094]
Rating: 10.0/10 (14 votes cast)
VN:F [1.9.3_1094]
Rating: +8 (from 8 votes)

Mac OS X Snow Leopard, PHP, MySQL, SVN, Xcode, and Me…

With minimal effort, I was able to get the PHP bundled with Snow Leopard to use the PHP extensions that I had compiled for xdebug, imagick, and magickwand to run in 64bit mode.

Snow Leopard comes bundled with Apache 2.2.11, PHP 5.3.0, and SVN 1.6.2.

I upgraded my MySQL install from 5.0.77 to 5.1.37 and then moved my data folder to another location to help keep things sane using the /etc/my.cnf file.

I installed the Xcode from the Snow Leopard CD and downloaded the iPhone SDK 3.1 Beta 3 for Snow Leopard.  Slightly different interface, but I welcome the changes.

So now, instead of using external packages for SVN and PHP (Entropy), now I’m using the prepackaged bundled software.  I did have to reconfigure my svn connection in Apache as it got toasted in the upgrade to Snow Leopard.  It wasn’t a problem though as it was only a few lines.

Now I can sleep good, I hope.

VN:F [1.9.3_1094]
Rating: 6.3/10 (3 votes cast)
VN:F [1.9.3_1094]
Rating: +1 (from 3 votes)

Mac OS X Leopard, Entropy PHP and XDebug Extension (64bit)

As all my entension in PHP must be compiled in 64bit to load into PHP, I’ve decided to give the details on how I added xdebug to Entropy PHP 5.2.5 beta 6 on Mac OS X Leopard running on an Intel Core 2 Duo.

First, download the source code for xdebug at the following site

XDebug (source code [2.0.4 as of this writing])

Then unpack the file into a directory someone on your system.

From the terminal, go to the folder where you unpacked everything. It should be xdebug-2.0.4. Then type the following commands:

  • cd xdebug-2.0.4
  • phpize
  • MACOSX_DEPLOYMENT_TARGET=10.5 CFLAGS=”-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp” CCFLAGS=”-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe” CXXFLAGS=”-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe” LDFLAGS=”-arch ppc -arch ppc64 -arch i386 -arch x86_64 -bind_at_load” ./configure –enable-xdebug
  • make

Now wait for it to complete the compiling process.  When it is done, begin these commands:

  • cd modules
  • chown root:wheel xdebug.so
  • sudo mv xdebug.so /usr/local/php5/lib/php/extensions/no-debug-non-zts-20060613/
  • cd /usr/local/php/php.d
  • sudo pico 50-extension-xdebug.ini

In the text editor, type the following line, then save the file with Control-O (WriteOut), then exit, Control-X.

zend_extension=/usr/local/php5/lib/php/extensions/no-debug-non-zts-20060613/xdebug.so

Once you’ve save the file and returned back to the terminal you can type in the following to restart Apache2:

  • sudo apachectl graceful

To make sure all went well, type in this to see if Xdebug is showing in the PHP information.

  • php -v

Should display something like this.

PHP 5.2.5 (cli) (built: Jan 24 2008 00:33:14)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
with Xdebug v2.0.4, Copyright (c) 2002-2008, by Derick Rethans

If the Xdebug v2.0.4 line shows up, then you’ve succesfully installed the 64bit version of Xdebug for Entropy PHP in Mac OS X Leopard.

VN:F [1.9.3_1094]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.3_1094]
Rating: 0 (from 0 votes)