TomatoCheese Blog

Installing Apache 2.2.4 with PHP 5.2.2 on Mac OS X 10.4.10

Posted by Joannou Ng on 2007.07.16 GMT at 02:05

Install Apache

Download and install Xcode Tools 2.4.1:
http://connect.apple.com/

Download and unarchive Apache 2.2.4:
http://httpd.apache.org/download.cgi

cd httpd-2.2.4

Configure Apache for Mac OS X, with all modules built as Dynamic Shared Objects, and use the bundled Apache Portable Runtime at build time:
./configure --enable-mods-shared=all --with-included-apr

Build Apache Universal Binaries (to integrate with Marc Liyanage’s PHP module):
CFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch ppc -arch i386" LDFLAGS="-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk -arch ppc -arch i386" make

Install Apache:
sudo make install

Configure Apache (Optional)

Edit the DocumentRoot and the corresponding Directory (in the Apache configuration file: /usr/local/apache2/conf/httpd.conf) to a friendlier folder:
DocumentRoot "/Users/your_os_x_short_name/Sites"
<Directory "/Users/your_os_x_short_name/Sites">

Test Apache

Stop Personal Web Sharing (if started)

Start Apache:
sudo /usr/local/apache2/bin/httpd -k start

Does it work?
http://0.0.0.0/

Install PHP

Download, unarchive, and install Marc Liyanage’s PHP 5.2.2 for Apache 2:
http://www.entropy.ch/software/macosx/php/

Ignore the “There were errors installing the software” message in Installer. That is because the PHP package’s postflight script failed to load the new PHP module into the old Apache by running the default apachectl.

Add the following line to the end of the new Apache configuration file, to load the new PHP module:
Include /usr/local/php5/entropy-php.conf

Test PHP

Restart Apache:
sudo /usr/local/apache2/bin/httpd -k restart

Create a phpinfo.php file in your Sites folder, with the following line:
<?php phpinfo() ?>

Got PHP?
http://0.0.0.0/phpinfo.php