BjarneDM
Registered
I've recently had a support question on how to compile PHP5 with gd as the 4.3.11 included with Tiger doesn't have that library activated.
A pre-requisite is of course to install the complete Apple XCode environment -otherwise you won't have any compilers installed and everything will fail miserably
The purpose is to compile PHP5 with as many extensions as possible. I'm getting the libraries needed from DarwinPorts - http://darwinports.opendarwin.org/ - as they seem to be more on top of new releases than fink - http://fink.sourceforge.net/ . I'm presently still working on getting freetype to work, but here are my results so far:
*** DarwinPorts ***
Before you install be sure to have installed the Apple X11 environment - otherwise we'll get into trouble when we want to install some of the packages. This includes both the X11User.pkg as well as the X11SDK.pkg from XCode
See this thread - http://www.macosx.com/forums/showthread.php?p=1245233#post1245233 - on how to do the basic DarwinPorts install
See this article on how keep DarwinPorts up do date: http://www.macosxhints.com/article.php?story=20051023105911376
Now in the directory we are using save the following as 'install.bash'
Make the script executable with 'chmod o+x install.bash'
Then execute : sudo ./install.bash ; and go get yourself a good dinner - this will take a while.
*** PHP5 ***
Make and enter the directory where we want to mess around with compling PHP5
In the above directory, save the following as 'php5.bash'
Make the script executable with 'chmod o+x php5.bash'
Then just run the following command: ./php5.bash 5.0.5
You'll have to modify you httpd.conf to load the php5.so instead of the php4.so if the php5 install script hasn't taken care of that. This is left as an exercise for the reader.
Also, in order to compile support for MySQL into PHP5 we'll have to install MySQL first. Se my separate thread on that.
****** NOTE ******
Normally I compile this for Apache2, but I'm 99% sure this'll work for the Apple Apache 1.3 . If you get into problems, we'll fix the above.
A pre-requisite is of course to install the complete Apple XCode environment -otherwise you won't have any compilers installed and everything will fail miserably

The purpose is to compile PHP5 with as many extensions as possible. I'm getting the libraries needed from DarwinPorts - http://darwinports.opendarwin.org/ - as they seem to be more on top of new releases than fink - http://fink.sourceforge.net/ . I'm presently still working on getting freetype to work, but here are my results so far:
*** DarwinPorts ***
Before you install be sure to have installed the Apple X11 environment - otherwise we'll get into trouble when we want to install some of the packages. This includes both the X11User.pkg as well as the X11SDK.pkg from XCode
See this thread - http://www.macosx.com/forums/showthread.php?p=1245233#post1245233 - on how to do the basic DarwinPorts install
See this article on how keep DarwinPorts up do date: http://www.macosxhints.com/article.php?story=20051023105911376
Now in the directory we are using save the following as 'install.bash'
Code:
#!/bin/bash
port install libiconv
# libxml2.2.dylib requires version 6.0.0 or later, but libiconv.2.dylib provides version 5.0.0
#the libiconv that comes with Mac OS X 10.4 is too old.
#Apache wants to get hold of the one in /usr/lib
#while PHP wants the one in /darwinports/lib
#to fix this problem the /usr/lib version is pushed aside:
mv -n /usr/lib/libiconv.2.dylib /usr/lib/libiconv.2.dylib.bak
cp -f /darwinports/lib/libiconv.2.dylib /usr/lib/libiconv.2.dylib
################################################################################
#The following ports need to be installed:
declare -a toInstall
toInstall=( \
aspell aspell-dict-en \
curl \
gettext \
jpeg libpng tiff \
libxml2 sablotron \
mhash libmcrypt \
openldap cyrus-sasl2
openssl \
pcre \
readline \
Xft2 \
zlib bzip2 \
)
for doInstall in ${toInstall[@]}
do
(port install ${doInstall}) ; wait
done
################################################################################
#in order to compile imap into PHP5 we need a file called c-client.a
#which is only present during part of the installation process of imap-uw
#likewise, we need some *.c and *.h files
#thus, the process is broken down into the constituent parts and at the proper
#time intervention occurs and the necessary files are extracted
port build imap-uw
imapLib=/darwinports/var/db/dports/distfiles/imap-uw/lib
imapIncludes=/darwinports/var/db/dports/distfiles/imap-uw/include
mkdir -pv ${imapLib} ${imapIncludes}
cd /darwinports/var/db/dports/build/*/*/*/c-client
cp *.c ${imapLib}
cp *.h ${imapIncludes}
cp -v c-client.a ${imapLib}/libc-client.a
cd ${imapLib}
ranlib - libc-client.a
port install imap-uw
Then execute : sudo ./install.bash ; and go get yourself a good dinner - this will take a while.
*** PHP5 ***
Make and enter the directory where we want to mess around with compling PHP5
Code:
mkdir -p ~/WebServer/PHP5
cd ~/WebServer/PHP5
Code:
#!/bin/bash
if [ ! -e php-${1}.tar.gz ]
then # you can replace the server with your own choice
curl -O http://dk2.php.net/distributions/php-${1}.tar.gz
fi
export PATH=/Developer/Tools:/Library/MySQL/bin:/bin:/sbin:/usr/bin:/usr/local/bin:/usr/sbin
sudo rm -rf php-${1}
tar -zxf php-${1}.tar.gz
sudo chmod -R 777 php-${1}
cd php-$1
./configure \
--prefix=/Library/PHP5 \
--with-apxs=/usr/sbin/apxs \
--disable-cgi \
--enable-magic-quotes \
--disable-short-tags \
--with-openssl=/darwinports \
--with-zlib=/darwinports \
--with-bz2=/darwinports \
--enable-bcmath \
--enable-calendar \
--with-curl=/darwinports \
--with-curlwrappers \
--enable-dba \
--enable-dbase \
--enable-dbx \
--enable-dio \
--enable-exif \
--enable-ftp \
--with-gd \
--with-jpeg-dir=/darwinports \
--with-png-dir=/darwinports \
--enable-gd-native-ttf \
--with-gettext=/darwinports \
--with-iconv=/darwinports \
--with-imap=/darwinports/var/db/dports/distfiles/imap-uw \
--with-imap-ssl=/darwinports \
--with-kerberos \
--with-ldap=/darwinports \
--with-ldap-sasl=/darwinports \
--enable-mbstring \
--with-mcrypt=/darwinports \
--with-mhash=/darwinports \
--with-mysql=/Library/MySQL \
--with-mysqli=/Library/MySQL/bin/mysql_config \
--with-ncurses=/usr \
--with-pspell=/darwinports \
--enable-shmop \
--enable-soap \
--enable-sockets \
--enable-wddx \
--enable-yp \
--with-libxml-dir=/darwinports/include/libxml2 \
--with-xmlrpc \
--with-expat-dir=/usr/X11R6 \
--with-xsl \
--enable-xslt \
--with-xslt-sablot=/darwinports \
--enable-shared \
--enable-static
make
sudo apachectl stop
sleep 30 # making sure apachectl has the necessary time to shut down all servers
sudo make install
sudo apachectl start
Then just run the following command: ./php5.bash 5.0.5
You'll have to modify you httpd.conf to load the php5.so instead of the php4.so if the php5 install script hasn't taken care of that. This is left as an exercise for the reader.
Also, in order to compile support for MySQL into PHP5 we'll have to install MySQL first. Se my separate thread on that.
****** NOTE ******
Normally I compile this for Apache2, but I'm 99% sure this'll work for the Apple Apache 1.3 . If you get into problems, we'll fix the above.