How to update Apache and PHP on Mac OS X 10.5 Leopard

Mac OS X 10.5 Leopard comes with Apache 2.2.6 and PHP 5.2.4 installed but not enabled. In order to enable them, follow this great tutorial here: http://foundationphp.com/tutorials/php_leopard.php.

After I was able to get Apache and PHP working, I noticed PHP didn’t have many extensions enabled. Specifically, I needed cURL, OpenSSL and SOAP extensions to be enabled. In order to enable more extensions, you will need to recompile the PHP 5 module.

I started by following the installation instructions from php.net (http://www.php.net/manual/en/install.unix.apache2.php). I skipped the Apache installation instructions and went right to the configure, make and make install of PHP.

Here are the steps I took:

cd /tmp
mkdir php
cd php
curl -O http://us.php.net/distributions/php-5.2.6.tar.gz
tar -xvzf php-5.2.6.tar.gz
cd php-5.2.6
./configure --with-apxs2=/usr/sbin/apxs --with-config-file-path=/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-soap --with-curl --with-openssl
make
sudo make install

Take note on a couple of the configure parameters I used:

--with-apxs2=/usr/sbin/apxs - Builds a shared Apache 2.0 Filter module.
--with-config-file-path=/etc - Sets the path where the php.ini configuration file is located.
--with-mysql=/usr/local/mysql - Includes MySQL support.
--with-mysqli=/usr/local/mysql/bin/mysql_config - Include MySQLi support.

Once my new PHP module was compiled I restarted Apache:

sudo /usr/sbin/apachectl restart

I then went to my browser to validate the installation with a phpinfo() page and the server was unresponsive. I commented out the PHP 5 module in the httpd.conf (/etc/apache2/httpd.conf) then restarted Apache and the page loaded, but obviously the phpinfo() did not render.

After realizing the PHP module was not loading correctly, I went and tried to run Apache manually:

sudo /usr/sbin/httpd

When Apache tried to start, I received this error message:

Cannot load /usr/libexec/apache2/libphp5.so into server: dlopen(/usr/libexec/apache2/libphp5.so, 10): no suitable image found. Did find:\n\t/usr/libexec/apache2/libphp5.so: mach-o, but wrong architecture

I did some searching and found this link with the answer: http://www.entropy.ch/phpbb2/viewtopic.php?t=2869.

It seems you will need to recompile Apache and provide the --enable-layout=Darwin parameter.

Here are the steps I took to update/recompile Apache:

cd /tmp
mkdir apache
curl -O http://www.ibiblio.org/pub/mirrors/apache/httpd/httpd-2.2.9.tar.gz
tar -xvzf httpd-2.2.9.tar.gz
cd httpd-2.2.9
./configure --enable-layout=Darwin --enable-mods-shared=all
make
sudo make install

After the install, I restarted Apache:

sudo /usr/sbin/apachectl restart

Now, when I load my phpinfo() page, I notice the cURL, OpenSSL and SOAP extensions are enabled!

In the end, I was able to update my version of Apache and update PHP with a new version and enabled extensions!

3 Responses to “How to update Apache and PHP on Mac OS X 10.5 Leopard”


Comments are currently closed.