PHP is the other key LAMP component that I insist on installing from source. A lot of PHP's functionality can be added in as modules, and a base PHP distribution installed via yum or RPM will include most or all of these modules for compatibility reasons. Some of them I'll never use, and some I've never even heard of. I definitely do not want the memory overhead of unused modules.
Make sure you have the following packages installed.
Download the latest PHP tarball from http://www.php.net/downloads.php into /usr/src/php.
This is the configure line I use. Your mileage may vary, but I'm fond of it. Please note that this is a very minimal set of options! If you start getting errors from PHP saying such-and-such function doesn't exist, you're missing a module, and you'll need to come back here, re-run the configure script with your module added, and recompile the whole thing.
Copy the example .ini file to a place where PHP will read it:
Verify some of the following settings. I'll give you the settings I use for a development box. You may want to change the error reporting level and/or logging for a production box. For zlib.output_compression, remember that we set up apache with mod_deflate,
so we don't want to compress output in PHP as well.
For a development machine, I use the following error settings:
On a production machine, you might want this instead:
The PHP install script may have added some or all of the necessary configuration lines in the Apache config file. The following options need to be set inside, so double-check each one in /etc/httpd/httpd.conf:
Restart apache. Try making a test page! If you've been following this guide straight through, just go to /srv/www and create a test.php page, and hit it with your browser.