Latest version of PHP available for RHEL5.x is 5.1.6 and no new RedHat releases are coming as packaging has ceased. You can get PHP 5.3 for RHEL5 from Remi, but it it’s incompatible with latest versions of Drupal, Civicrm or many modules so we need the a 5.2X branch of PHP. This requires building php from source or using rpmbuild and source rpm. I was able to use Koji’s FC9 php5.2.9 src.rpm to rebuild for RHEL5 and here is how.
Install rpm-build package.
1
|
|
Create build env in your home directory (mine is called ‘max’), do NOT build as root user. I used ‘rpm’ directory as the build location.
1
|
|
Create .rpmmacros file which will identify the build location.
1
|
|
Download php5.2.9 rpm source file, i used FC9 version as it is closest to RHEL5.
1
|
|
To rebuild php5.2.9 FC9 source RPM for RHEL5.x into binary RPM’s we need to make sure build dependences have been satisfied. I created a file called “php-deps” which contains the build dependencies to be installed via YUM.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
|
Install build dependencies via yum
1
|
|
Finally perform the build, this could take some time depending on speed of your machine. If everything goes well many php*.rpm files will be created in rpm/RPMS/”arch-type”/ folder. “arch-type” is the hardware-platform of your machine which will match “uname -i” command (mine is i386)
1
|
|
Now you can install the resulting RPM’s manually but a better way is to create a local YUM repository. Install createrepo application via YUM.
1
|
|
Create a repository location directory and copy your newly generated php5.2.9 RPM files into it.
1
|
|
Initialize the local repository and catalog the files copied there. (run this command anytime you add/remove files from your local repository directory)
1
|
|
Configure your local repository with yum by creating a file in /etc/yum.repos.d called “local-repository.repo” containing:
1 2 3 4 5 6 |
|
Update yum to register local repository
1
|
|
Update php using your new rpm files via the local repository
1
|
|
Restart apache
1
|
|
Verify PHP version
1
|
|