Update 20th June 2009 – I found a bug in PHP 5.2.9, so I have compiled 5.2.9 rpms, including the ones that this article talks about, check out the article here.
Update 23rd May 2009 – It appears dbase, readline, json and filter were included either compiled into php or as a shared module in php-common, so I’ve removed them from the spec.
In using the installation of PHP 5.2.6 on CentOS, I noticed that there were a few modules missing from the repository that are included as part of CentOS’s extras repository. They are nowhere to be found in the testing repository.
I found an easy way to build the RPM’s by downloading both the testing php source RPM (SRPM), and the extras php-extras-5.1.6 SRPM, rewriting the php-extras spec file so it incorporated the same patches, and building it as the php-5.2.6 version.
The php-extras include the dbase, readline, mcrypt, mhash, tidy and mssql extensions. In my spec file, I have removed dbase and readline, as they have moved to php-common. I have also included the newly added extensions to php 5.2; json and filter. In future versions of CentOS, these should hopefully be updated in the extras or the base repository.
The steps that are needed:
Set up a source RPM build environment
useradd mockbuild mkdir /usr/src/redhat yum install rpm-build
Download and install the SRPMs, so that their build files are in the environment
wget http://mirror.centos.org/centos/5.3/extras/SRPMS/php-extras-5.1.6-15.el5.centos.1.src.rpm wget http://dev.centos.org/centos/5/testing/SRPMS/php-5.2.6-2.el5s2.src.rpm rpm -i php-extras-5.1.6-15.el5.centos.1.src.rpm rpm -i php-5.2.6-2.el5s2.src.rpm
Save this php-extras.spec file to /usr/src/redhat/SPECS/php-extras.spec. The changes I have made reference the patches contained in the php SRPM, and have dbase and readline removed.also include the json and filter extensions to be built into RPMs as well.
Now run the build process
rpmbuild -ba /usr/src/redhat/SPECS/php-extras.spec
You will probably get an error at the start e.g.
error: Failed build dependencies:
freetds-devel is needed by php-extras-5.2.6-1.1.i386
libtidy-devel is needed by php-extras-5.2.6-1.1.i386Install all of the packages mentioned, e.g.
yum install -y freetds-devel libtidy-devel yum --disablerepo=* --enablerepo=c5-testing install php-devel
Now run the build process again, and by the end, you should have both an SRPM and the RPMs of the php extras.
You can put these in a repository or install them as the following:
rpm -i /usr/src/redhat/RPMS/i386/php-tidy-5.2.6-1.1.i386.rpm
Thank you very much…
Worked for me. I had to upgrade PHP from 5.1.6 to 5.2.6 to fix an issue with Horde webmail compression and immediately ran into the no mcrypt and no tidy issue.
Followed the instructions and all sorted.
Nope – it’s really stubborn about the whole 5.1.6 thing:
# rpmbuild -ba /usr/src/redhat/SPECS/php-extras.spec
error: Failed build dependencies:
php-devel = 5.2.6 is needed by php-extras-5.2.6-1.1.i386
#yum install php-devel <- doesn’t work
#yum install php-devel = 5.2.6 <- doesn’t work
#yum install php-devel=5.2.6 <- still doesn’t work
message is:
Package php-devel-5.1.6-23.2.el5_3.i386 already installed and latest version
Nothing to do
or “no package available”
This is way too weird and frustrating.
Magento doesn’t work with anything less than php 5.2 and it seems that CENTOS 5.3 doesn’t work with php greater than 5.1.6…
I’ve tried 3 completely different ways to get it installed. Is there a definitive way to get this upgraded?
Thanks,
Dana
Have you had a look at my guide for installing PHP 5.2.6? This is needed before building. CentOS 5.3 doesn’t have that version in its standard repositories.
http://www.webtatic.com/blog/2009/05/installing-php-526-on-centos-5/
Hi Andy,
Yes, I did this look at and follow the guide for installing PHP 5.26 first. Then I followed installing-php-526-extra-extensions…
So just now, I did the “installing-php-526-on-centos-5″ instructions again and this was the result:
#yum update
Loaded plugins: fastestmirror, priorities
Loading mirror speeds from cached hostfile
* base: mirror.raystedman.net
* updates: mirrors.xmission.com
* contrib: centos.g5selfstorage.com
* centosplus: mirror.fdcservers.net
* addons: centos.g5selfstorage.com
* extras: mirrors.easynews.com
base | 1.1 kB 00:00
updates | 951 B 00:00
contrib | 951 B 00:00
centosplus | 951 B 00:00
addons | 951 B 00:00
extras | 1.1 kB 00:00
Excluding Packages from CentOS-5 – Base
Finished
Excluding Packages from CentOS-5 – Updates
Finished
93 packages excluded due to repository priority protections
Setting up Update Process
No Packages marked for Update
#
So I don’t think yum is doing anything…
Am I correct, or should I see this result and then move on to the other article?
Thanks for responding Andy,
Dana
Wow, thought I found the answer on another site:
http://bluhaloit.wordpress.com/2008/03/13/installing-php-52x-on-redhat-es5-centos-5-etc/
I followed the instructions and it looked like it did something, but then got hung up on MySql (why are PHP and MySql married/ conjoined at the back of the head?)
[root@bagvapp ~]# php -v
PHP Warning: Module ‘PDO’ already loaded in Unknown on line 0
PHP Warning: Module ‘pdo_mysql’ already loaded in Unknown on line 0http://bluhaloit.wordpress.com/2008/03/13/installing-php-52x-on-redhat-es5-centos-5-etc/
PHP 5.1.6 (cli) (built: Apr 7 2009 08:00:04)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
[root@bagvapp ~]#
So I had to remove MySql – which seems like the wierdest thing to do and followed the instructions again, and reinstalled MySql.
Now it looks like I have version 5.2.9 – I guess just for the heck of it I have 5.2.9 now… Okay, I guess that’s better than 5.2.6…
Well Andy, I’m not sure what happened, and I think it’s a shame people have to jump through hoops to figure out how to install software…
Dana
Hi Dana,
It seems like you might have missed a step from my other guide, as it would have definitely allowed you to install php-devel-5.2.6. From the looks of your yum update, the centos testing repo wasn’t enabled. I’ve simplified that article by using an easier way of installing the RPMs.
I guess the main problem is the extra trouble you need to go through to generate these RPMs. I didn’t really want at the time to provide yet another unknown/untrusted repository, so I explained my steps from the CentOS official repositories and RPMs.
I’ve closed comments for this article, as I wrote a new article later that explains installing PHP 5.3 from my own repository.
See PHP 5.3 on CentOS