Running PHP in Red Hat

Submitted by othniel@netscape.net and dmcaruso@netscape.net.

PHP is a server-side programming language for producing dynamic web content. Language constructs can be embedded within a standard HTML document by changing the extension from .html to .php or by processing all .html files with the PHP language processor similar to .shtml (SSI). The language is especially amenable to forms processing, backend database access, graphics rendering and object-oriented applications where file attachments (uploads) are desired. Since PHP is available as an Apache module (library), performance is enhanced over an equivalent CGI solution requiring a fork/exec. Numerous C libraries have been imbedded to extend its applicability in many useful areas.

The following instructions describe how to get PHP setup on a RedHat 6.0 Linux box using only RPM. The document assumes that you have prior experience configuring/using Apache.

Install the RPM package php-3.0.12-4.i386.rpm available for download from http://rpmfind.net/linux/RPM/PbyName.html:

Note: To accomplish this on my RedHat 5.2 box, the rpm dependencies required me to simultaneously upgrade to apache-1.3.9-1 glibc-2.1.2-9 and freetype-1.2-6 which are also available at the rpmfind.net website.

Note: You must pay attention to all notices produced by the RPM upgrade process. When the upgrade process installs a new base configuration file, the original configuration files are renamed to an rpmsave extension and a small notice to that effect is your only warning that your configuration files will no longer be used. For the Apache Web Server you are likely to not notice this until your next reboot.

Optionally install the RPM package php-manual-3.0.12-4 from rpmfind.net. If you decide to install this package, the PHP manual may be browsed with a web browser at http://localhost/manual/mod/mod_php, where <localhost> is either the word "localhost" or the name of the machine on which the PHP man pages are installed.

Configure Apache to load the PHP language processor as described at http://www.php.net/FAQ.php, section 3.2. Edit the Apache configuration file using your favorite text editor thus:
vi /etc/httpd/conf/httpd.conf

Find & uncomment the following lines:

LoadModule php.module /usr/lib/apache/libphp.so
AddModule mod_phpc

I had to change the LoadModule from the original "modules/libphp.so" to the above to get my system to work, contrary to the instructions found in the PHP FAQ. I was unable to get apache-1.3.3-1 to work with php on my RH5.2 system, but if you are using an older version of Apache (like 1.3.3-1), you may have to enable php processing in your srm.conf like:

AddType application/x-httpd-php .php

This is included automatically (conditionally) as you can verify in apache-1.3.9-1's unified httpd.conf file.

Restart apache as follows:

cd /etc/rc.d/init.d
./httpd restart

This kills and restarts Apache. Any/all error messages will be displayed to your tty.

Start with a simple "Hello, World" php web page from the PHP Tutorial at http://www.php.net/tut.php to verify that php interpreter is functioning properly. Locate your hello.php file in a web directory you already know is working for html documents.

Additional resources can be found at http://php.net