http://www.google.com/profiles/dag.endresen

Monday, January 5, 2009

OS X system upgrades and my Apache HTTPD + PHP

OS X Leopard and compiling Apache HTTPD + PHP

I have a MacBook with my own build for the Apache HTTPD + PHP. I need features for my PHP system not included in the generic bundle with OS X Leopard (PostgreSQL). Some of the add-ons for PHP are 32 bit, so I need to build my own 32 bit Apache HTTPD. For convinience I wanted to compile the new version of Apache HTTPD and PHP to the folder directory as the default bundled OS X versions. This provides easy management from the System Preference panel etc.

Apache HTTPD
Download the latest source code from: http://httpd.apache.org/download.cgi.
Use the command line prompt with a terminal window.

Uncompress for example to /usr/local/src/
  • tar xzvf http.2.2.11.tar.gz (option z for gz compression file.tar.gz)
  • tar xjvf http.2.2.11.tar.gz (option j for bzip2 compression file.tar.bz2)
Enter the source code directory: (cd /usr/local/src/http.2.2.11/)

Give your local configure option for the compilation. I use:
./configure \
--enable-layout=Darwin \
--enable-mods-shared=all \
| tee INFO_httpd_configuration.txt

The option --enable-layout=Darwin provides the trick to compile your own version of the HTTPD web server to the very same directory location as the OS X Leopard web server (/usr/local/apache2/, /usr/libexec/apache2/). You may want to create a backup of these directories!

The pipe (|) to tee is NOT neccessary, but give a handy text file with a log of the output to standard output during the execution of the configuration command. The tee application will let the standard output through to the screen as well as also to the text file you specify.

Next make and make install:
make | tee INFO_httpd_make.txt
sudo make install | tee INFO_httpd_make_install.txt


PHP
Compiling PHP exactly as you will require some efforts to get all the external libraries and support applications you want to have installed. Fink and MacPort may be very useful if you have problems to compile them yourself, or if you simply do not require any particular configuration settings.

My configuration settings:

'./configure' \
'--enable-layout=Darwin' \
'--with-config-file-path=/etc' \
'--sysconfdir=/private/etc' \
'--disable-dependency-tracking' \
'--enable-dbase' \
'--enable-cli' \
'--enable-exif' \
'--enable-ftp' \
'--enable-mbregex' \
'--enable-mods-shared=all' \
'--enable-mbstring' \
'--enable-soap' \
'--enable-sockets' \
'--enable-trans-sid' \
'--infodir=/usr/share/info' \
'--localstatedir=/var' \
'--mandir=/usr/share/man' \
'--prefix=/usr' \
'--with-apxs2=/usr/sbin/apxs' \
'--with-curl=/usr' \
'--with-gd' \
'--with-iodbc=/usr' \
'--with-jpeg-dir=/usr/local/bin' \
'--with-kerberos=/usr' \
'--with-ldap=/usr' \
'--with-mysql=/usr/local/mysql' \
'--with-mysql-sock=/var/mysql' \
'--with-mysqli=/usr/local/mysql/bin/mysql_config' \
'--with-pdo-mysql=/usr/local/mysql' \
'--with-pdo-pgsql=/usr/local/pgsql/bin' \
'--with-pgsql=/usr/local/pgsql' \
'--with-png-dir=/usr/local/bin' \
'--with-tidy=/opt/local' \
'--with-xmlrpc' \
'--with-xsl=/usr' \
'--with-zlib' \
'--with-zlib-dir=/usr' \
'--without-pear' \
| tee INFO_php_configuration_log.txt

Next make and make install:
make | tee INFO_php_make.txt
sudo make install | tee INFO_php_make_install.txt

With --enable-layout=Darwin the compiled PHP libraries will find their way to the save directory location as the default bundeled PHP with OS X Leopard. If you prefer to be more careful, you may compile your PHP without the "--enable-layout=Darwin" and instead for example "--prefix=/usr/local/php5". In the sub-folder "libs" in the source code folder were you compiled PHP you will find "libphp5.so". You may manually copy this to "
/usr/libexec/apache2/" if the library file does not arrive there during the make install.


OS X system upgrades
Most of the OS X system upgrades destroys my own web server compilation. The central problem seems to be that a generic OS X HTTPD of 64 bit replaces my own HTTPD. The fix is however rather simple. Save and keep the source code you used to compile your HTTPD web server, for example in /usr/local/src/httpd.2.2.11/. Execute make install from the source code folder. If a new version of HTTPD is available, I usually download this one and run the ./configure && make && make install as described above.

You may check your version of the Apache HTTPD web server from the command prompt with: httpd -V. Look for the line "Server version: Apache /2.2.11" for your web server version and the "Architecture: 32-bit" or "Architecture: 64-bit". You may also want to verify the local of the httpd application with the command: which httpd. The default location for OS X Leopard is /usr/sbin/httpd. If you have other httpd application from for example fink or MacPorts you may see another path to the httpd. You may check your PATH with: echo $PATH.

No comments:

Post a Comment

Followers

Powered By Blogger