Archive

Archive for March, 2008

HOW-TO: Compile PHP/Apache2.2 on OS X Leopard

March 1st, 2008

I’ve been fighting my Leopard installation recently with getting the IMAP libraries compiled correctly. I wanted the IMAP features so that I could use my sugarCRM application better. After a lot of fighting, compiling and adjusting, I finally got a stable installation of Apache 2.2 and PHP-5.2.5 with IMAP. Here’s how I did it:

I didn’t want to ruin the installation of Apache2.2 that comes native on Leopard, so I started from scratch:

cd /usr/local
mkdir src
curl -O http://www.mirrorgeek.com/apache.org/httpd/httpd-2.2.8.tar.gz
tar -zxvf httpd-2.2.8.tar.gz # a bunch of output will fly by; that’s normal
cd httpd-2.2.8
./compile –enable-so –prefix=/usr/local/apache2 # a ton more output will fly by
make
sudo make install

Now we have a new apache install in your /usr/local directory. If you want to connect this installation to your usual web directory on your mac, you need to edit your httpd.conf to direct your web root folder to /Library/WebServer/Documents. You do this by executing the following commands:

sudo vi /usr/local/apache2/conf/httpd.conf
Change DocumentRoot “/usr/local/apache2/htdocs” to: DocumentRoot “/Library/WebServer/Documents”
Next, change to
issue the vi command :wq

Your Apache Installation should be set to go now.

Before we can install php, we need to cimpile the IMAP c libraries. Go to and download these libraries at ftp://ftp.cac.washington.edu/imap/ . Then, move them to your source directory with the following command:


mv ~/Downloads/[your-imap-download] /usr/local/src
./compile –prefix=/usr/local/imap
make
sudo make install

When this finishes, you can install php

PHP Installation:

Go to http://us3.php.net/get/php-5.2.5.tar.gz/from/a/mirror and download a package
On Leopard, you would issue the following command to move the package to our source directory:

mv ~/Downloads/php-5.2.5.tar.gz /usr/local/src

Now, we compile:

tar -zcvf php-5.2.5.tar.gz
cd php-5.2.5
./configure –prefix=/usr/local/apache2/php –with-apx2=/usr/local/apache2/bin/apxs –with-imap=/usr/local/imap –with-mysql=/usr/local/mysql
make
sudo make install

Following the completion of this install, you should be able to issue the command:

sudo /usr/local/apache2/bin/apachectl start

and your installation is complete. SugarCRM should recognize the imap libraries and php should run smoothly.

Please note that this is not a particularly secure installation, but will work great for local intranets to keep your users involved with the crm.

Please post comments if you run into trouble.

HowTo, technology