Some notes for RedHat 5.x/6.x users =================================== These instructions assume you want to use pre-built RPM's as much as possible. There is nothing stopping you from grabbing the Apache and PHP tarballs and working completely from sources. Simply follow the instructions in the INSTALL file. But if you like having most things under rpm control, read on. *Warning* these instructions will not work with the stock Apache rpm that comes with RedHat-6.1 due to a bug introduced by RedHat. If you are using RH-6.1, make the following change before continuing: On or around line 81 of your /usr/sbin/apxs file, you will see a line like this: my $CFG_LIBEXECDIR = 'modules'; # substituted via APACI install Change this to be: my $CFG_LIBEXECDIR = '/usr/lib/apache'; # substituted via APACI install While you are looking at this file, make sure the $CFG_LD_SHLIB and $CFG_LDFLAGS_SHLIB are set to something close to this: my $CFG_LD_SHLIB = 'gcc'; # substituted via Makefile.tmpl my $CFG_LDFLAGS_SHLIB = q(-shared); # substituted via Makefile.tmpl If your /usr/sbin/apxs script has these lines along with the change to the $CFG_LIBEXECDIR line, you are ready to proceed. The first thing you need to do is upgrade your Apache to at least version 1.3.6. You need the apache-1.3.6 rpm along with the apache-devel RPM. RedHat-6.0 comes with apache-1.3.6, but by default it does not seem to install the apache-devel rpm. Grab that one and install it as well. While you are at it, upgrade to Apache-1.3.9 or later. There are a number of fixes, and if you are running glibc-2.1.1 you will definitely need it. RedHat also has an annoying habit of not installing other -devel packages. The one that gets the most people is freetype-devel. Save yourself some trouble and grab the freetype-devel rpm and install it before configuring PHP. You can check if you have it installed by typing: rpm -q freetype-devel You will also need the PHP tarball. The PHP rpm available from RedHat is ok if you don't need database support or any of the other PHP add-ons. If you do need to add your own set of features, download the latest PHP tarball and follow the steps below: Step 1: Remove old Apache packages, if older version is installed. rpm -e apache rpm -e apache-devel Step 2: Install new Apache packages if necessary and any missing -devel packages rpm -i apache-1.3.6-7.i386.rpm rpm -i apache-devel-1.3.6-7.i386.rpm rpm -i freetype-devel-1.2.6.i386.rpm Step 3: Determine which PHP extensions you want to use ./configure --help This will give you a list of all the available options. See the "PHP Extensions" section of this file for specific instructions on how to build in support for each extension. Step 4: Build PHP A typical configure line would look like this: ./configure --with-apxs=/usr/sbin/apxs --with-mysql --with-ldap (note that you may need /usr/bin/apxs here - check where your apxs is) (Add --with-xml if you are using Apache-1.3.9 or later) Then type: make make install The 'make install' step should produce something very similar to: /usr/sbin/apxs -i -n php3 libphp3.so cp libphp3.so /usr/lib/apache/libphp3.so chmod 755 /usr/lib/apache/libphp3.so At this point you just need to tell your server to load and activate the php module. Your /etc/httpd/conf/httpd.conf and /etc/httpd/conf/srm.conf files already have the appropriate lines in them to do this. You simply have to uncomment them. Edit these two files and make sure the following lines are uncommented: in /etc/httpd/conf/httpd.conf: LoadModule php3_module libexec/libphp3.so AddModule mod_php3.c And in /etc/httpd/conf/srm.conf: AddType application/x-httpd-php3 .php3 AddType application/x-httpd-php3-source .phps (Uncommenting these lines means you need to remove the # character at the beginning of each of these lines) Once you have done this you need to restart your server with a command like the following: /etc/rc.d/init.d/httpd restart NOTE: If you get an error at this point saying that the libphp3.so file could not be found, it is likely because you are using the RedHat rawhide apache-1.3.4 rpm. To fix it, type: ln -s /usr/lib /etc/httpd and then start your server with: /etc/rc.d/init.d/httpd start If you see something like this error: "Cannot load /usr/modules/mod_env.so into server: /usr/modules/mod_env.so: cannot open shared object file: No such file or directory" You need a link like this: ln -s /usr/lib/apache /usr/modules Apache and apxs don't always seem to agree on where to load the modules from, so look at the error message and create the appropriate link. Also, make sure you have both a LoadModule *and* and AddModule line for php. The LoadModule line has to appear before the AddModule line, and it needs to be in the same order with respect to the other AddModule lines as the LoadModule line. That is, if your LoadModule line is the last of its kind, then the AddModule line needs to be the same. The lines themselves should look something like: LoadModule php3_module modules/libphp3.so AddModule mod_php3.c Also, doublecheck that you have a line like this in one of your .conf files: AddType application/x-httpd-php3 .php3 You do not need to use the .php3 extension. Set this to whatever you like. Whichever extension you choose here will be the one that tells Apache to feed the file through the PHP parser. Step 5: Test your setup Create a file in your document root directory. I usually call it info.php3 and in it put this single line: Then load it up in your browser: http://your.machine/info.php3 You should see a nice summary page showing all sorts of information about your setup. You probably shouldn't leave this file around on a production server, but for debugging and general info during development, it is very handy. PHP Extensions ============== In all cases, it is a good idea to remove the 'config.cache' when trying to reconfigure PHP to include new options. Package Suggested ./configure swicth ------- ---------------------------- GD You need the standard gd-devel RPM installed. PHP will automatically detect it and include support for it if the gd-devel RPM has been installed. FreeType (libttf) You need to install the freetype and freetype-devel RPM's available from any RedHatContrib mirror site. Once installed PHP will automatically detect them and add TTF stuff. Note that you also need GD support for TTF support to be activated. ImageMagick -with-imagick You need the bzip2 RPM along with the ImageMagick-devel-4.2.0-1 RPM or later. IMAP --with-imap Get the latest imap-devel RPM from a RedHatContrib mirror site and install it. LDAP --with-ldap Get the latest openldap-libs and openldap-devel RPM's from any RedHatContrib mirror site. mSQL --with-msql=/usr/lib/Hughes Get the msql RPM from a RedHatContrib mirror MySQL --with-mysql Grab the latest rpm packages directly from http://www.tcx.se or a mirror. You should get all three. MySQL, MySQL-client and MySQL-devel, but the only package required in order to compile in MySQL support in PHP is the MySQL-devel RPM. PostgreSQL --with-pgsql You need the postgresql-devel RPM SNMP --with-snmp You need the ucd-snmp-devel RPM YP --with-yp libnsl contains the functions for this one and should already be installed. It is usually part of the glibc-devel RPM. Zlib --with-zlib You need the standard zlib-devel RPM (version >= 1.0.9) installed.