I first used httpd-2.0.43 and php-4.3.0 with RedHat 7.3. I am now using httpd-2.2.3 and php-5.2.0 with SUSE 10.1.
Note: If you have problems with PHP and think it’s a recent bug, you may want to consider using the latest http://snaps.php.net/ snapshot. Beware that snapshots frequently have regression and are not for production use. Usually problems are because of mis-configuration, not bugs, so snapshots will probably hurt more than help.
1. Download/unpack Apache2 source from the Apache httpd server website, http://httpd.apache.org/
2. In the Apache 2 source directory, create a Makefile by typing:
./configure –prefix=/usr/local/apache \
–enable-so \
–enable-cgi \
–enable-info \
–enable-rewrite \
–enable-speling \
–enable-usertrack \
–enable-deflate \
–enable-ssl \
–enable-mime-magic
You only need the enable-so line above. For information on other options, type ./configure –help and see “Compiling and Installing” in the Apache 2 Documentation, http://httpd.apache.org/
3. Make Apache from the just-created Makefile:
make
4. If make is successful, install Apache as root:
make install
5. Download/unpack PHP source from the PHP website, http://www.php.net/
Pick the latest from the 4.x series or 5.x series.
6. In the PHP source directory, create a Makefile by typing:
./configure \
–with-apxs2=/usr/local/apache/bin/apxs \
–with-mysql \
–prefix=/usr/local/apache/php \
–with-config-file-path=/usr/local/apache/php \
–enable-force-cgi-redirect \
–disable-cgi \
–with-zlib \
–with-gettext \
–with-gdbm
You only need the –with-apxs2, and prefix lines. –with-mysql adds MySql, –with-config-file moves the php.ini file location, disable-cgi disables the CGI version, which is not needed if you use Apache modules. It also enables and installs the command line interface (CLI) version. –with-zlib allows use of gzip-type compression, –with-gettext is for internationalization, and –with-gdbm allows access to GDBM databases. For more information, type ./configure –help and see the “Installation” chapter in the PHP Manual, http://ww.php.net/docs.php
7. Make PHP from the just-created Makefile:
make
8. If make is successful, type this as root to install PHP:
make install
If you are not root (I do not perform makes while root, for security and safety reasons), become root and type the following:
make install-su
9. If file /usr/local/apache/modules/libphp5.so does not exist or is an older version, type this (change this to libphp4.so for PHP 4):
cp -p .libs/libphp5.so /usr/local/apache/modules
10. Install the php.ini file:
cp -p php.ini-recommended /usr/local/apache/php/php.ini
11. Add these directives are in /usr/local/apache/conf/httpd.conf (if already there, verify they are correct):
# Make sure there’s only **1** line for each of these 2 directives:
# Use for PHP 4.x:
#LoadModule php4_module modules/libphp4.so
#AddHandler php-script php
# Use for PHP 5.x:
LoadModule php5_module modules/libphp5.so
AddHandler php5-script php
# Add index.php to your DirectoryIndex line:
DirectoryIndex index.html index.php
AddType text/html php
# PHP Syntax Coloring
# (optional but useful for reading PHP source for debugging):
AddType application/x-httpd-php-source phps