Below is an outline on how to compile a feature rich, PHP Apache module on Fedora 9. First, compile Apache on the system using these instructions. This document assumes that Apache and the APache eXtenSion Tool are installed in the PREFIX: /opt/apache2.
Once you have Apache prepared, download the PHP source from php.net. As of August, 2008 the latest version is PHP 5.2.6. So, the following examples will use the php-5.2.6.tar.gz source tarball. Use your browser to download the latest and greatest. Then, untar the source.
tar -xzvf php-5.2.6.tar.gz cd php-5.2.6
Next, configure the source for compile. Use the configure command. You can provide –help to see the large list of options.
For every option you enable, make sure you have the necessary RPMs installed to build PHP. For example, if you run configure with –with-snmp, you will need the net-snmp-devel RPM installed to complete the build. To ensure that you can build PHP with a full suite of options, install the following RPMs. Trim the list to suit your needs.
yum install aspell-devel curl-devel cyrus-sasl-devel e2fsprogs-devel freetype-devel glibc-devel keyutils-libs-devel krb5-devel libgcc libidn-devel libjpeg-devel libpng-devel libselinux-devel libsepol-devel libstdc++-devel libX11-devel libXau-devel libXdmcp-devel libxml2-devel libXpm-devel mysql-devel net-snmp-devel openldap-devel openssl-devel tcp_wrappers zlib-devel
Then, configure with the following settings. Change the configure –prefix to adjust your install PREFIX. Again, trim the list to suit your needs.
./configure --prefix=/opt/php5 --with-apxs2=/opt/apache2/apxs --with-mysql=/usr/bin/mysql_config --with-mysqli=/usr/bin/mysql_config --with-png-dir=/usr --with-gd --enable-gd-native-ttf --with-ttf --enable-safe-mode --enable-magic-quotes --with-pspell --with-gettext --with-jpeg-dir=/usr --with-zlib --with-curl --enable-soap --with-ldap=/usr --enable-sockets --with-openssl --with-snmp --enable-mbstring --with-freetype-dir=/usr --with-xpm-dir=/usr --with-libdir=lib64
Please note that if you are on a 32bit system, remove:
Finally, build PHP and test it.
make make test
If you are comfortable with the results (a few errors are OK in make test), then install PHP.
sudo make install
The install will place the PHP module in /opt/apache2/modules and prepare /opt/apache2/conf/httpd.conf with these settings:
LoadModule php5_module modules/libphp5.so
Then, place a php.ini in /opt/php5/lib (or your PREFIX/lib).
cp -a php.init-recommended /opt/php5/lib/php.ini
Finally, prepare your Apache Virtual Host to support index.php with the following code:
AddType application/x-httpd-php .php .inc .class AddType application/x-httpd-php-source .phps DirectoryIndex index.html index.php