As part of building up my dev environment at ETI I had to install Apache2.2 and PHP5 on Red Hat 5. Here are my install notes.
Do this as root.
First download the source for Apache and PHP. This command will get the file from the URL and put it at your present location.
Unzip and untar the Apache Archive
Switch into the apache directory created from untarring the file.
Configure Apache with Dynamic Object support so that you add new modules easily at a later time.
#./configure ./configure --enable-so
Done. Now you can test by starting and stopping the server
#/usr/local/apache2/bin/apachectl -k [start | stop]
If there are no errors when running it you should be able to browse to the test page:
Repeat the unzip and untar instructions above for the PHP archive.
Configure PHP with options you need. In my case I need mysql, cURL and SOAP. Notice the first option with the path to apxs. This is actually going to compile the PHP module and move it to Apache’s module directory. This is also used later when want to build and install new Apache modules.
#./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql --with-curl --enable-soap
Then you want to move the distributed PHP config file to the final location. In my case it was this:
#cp php.ini-dist /usr/local/lib/php.ini
You also need to edit the Apache config file to tell it to process PHP files. I put this at the end of my httpd.conf file.
Finally I wanted to install mod_rewrite. In the directory that contains the source files look for the modules directory that contains the module you need. In my case it is mappers. Then I ran this command which compiles and installs the mod_rewrite module.
#/usr/local/apache2/bin/apxs -i -a -c mod_rewrite.c
Restart Apache and off you go.