Upgrading PHP on RHEL 4.6

I currently have a RHEL4.6 server that is hosting a MediaWIki v1.6.12 sire. The reason I stayed with that version for so long is that the default LAMP stack could properly run it without updating. But my users have requested a more current version be install so now it is time to upgrade it.   So starting out, I have RHEL4.6 which give us Apache 2.0.52, MySql 4.1, and Php 4.3. I looked into and found that I met all the requirements for the newest version except for php. I would rather not deal with upgrading mysql if i can avoid it. So I am simply going to build php from source.   First thing, just to be safe, bring your site down.

 

service httpd stop && service mysqld stop

To start with, remove the installed version of php

rpm -qa | grep php
rpm -ev <the_listed_php_packages>

Download the current source code of php from php.net and extract it. I went with version 5.2.17.

wget -c http://us3.php.net/get/php-5.2.17.tar.gz/from/this/mirror
tar -xzf php-5.2.17.tar.gz
cd php-5.2.17

Next ensure you have a few required packages before you start.

up2date httpd-devel
up2date mysql-devel
up2date mysqlclient10-devel
up2date zlib-devel

Now let try to build it.

./configure --with-apxs2=/usr/sbin/apxs --with-mysql 
              --libdir=/usr/lib64 --with-libdir=lib64 --with-zlib
make
make install

Next copy the php.ini template.

cp php.ini-recommended /usr/local/lib/php.ini

Now we just setup the php.conf file for Apache and we are done. The instructions on the php site have you put everything into the http.conf file, but I feel that goes against the modular design of Apache. I used a previous php.conf file from another server as a temple.

Remove the LoadModule php5 line from the http.conf file that was inserted during the build. We will include it into out php.conf.

# Place the following into your /etc/httpd/conf.d/php.conf

—————————————————————————————————————————–

<IfModule prefork.c>
LoadModule php5_module /usr/lib64/httpd/modules/libphp5.so
</IfModule>

AddHandler php5-script .php
AddType text/html .php

DirectoryIndex index.php

——————————————————————————————————————————

We are done now. Restart your apache server and test the configuration by placing the following script called index.php into your DocumentRoot of your webserver.

<!--?php phpinfo(); ?-->

Leave a Reply

Your email address will not be published. Required fields are marked *