Install PHP 5.2 on CentOS 5.2 Using Yum
Yum is a standard installation utility for CentOS 5.2. One of the reasons I favor CentOS over other Linux distros is actually because it comes with yum. It is that good!
Unfortunately, CentOS 5.2 does not generally include the latest versions of libraries, because it follows conservative path of the RedHat Enterprise. Which is not that bad of an idea, for a server OS... until you need that latest version of something and you are stuck... or: not necessarily.
If you a are a Drupal developer, there's a very good reason why you need the latest version of PHP: 5.2. The reason is called FileField module. This module is required by another absolutely essential module ImageField making it a matter of life-or-death (just kidding) to have PHP 5.2 on your server. But the latest CentOS release (ironically also 5.2) only comes with PHP 5.1.6.
What to do?
Some people on the Net suggest installing Fedora RPMs. Not such a good idea, since PHP also has a bunch of its own extensions that RPM will not like the versions of and going down that path will quickly prove being extremely painful. Also, if you install custom RPMs, you lose the benefits of Yum and that's not good at all. Compiling from source, is even worse of an idea, for all the same reasons, of course.
Like I already mentioned, yum is awesome and one of the awesome things it allows is to attach to third-party repositories. So you can still install newer versions of certain RPMs if you need to.
A third-party Yum repo simply means that somebody else went through the pain for you (thank you, Somebody!) and now you can use the benefits of their work, plus continue using yum to manage versions. Nice!
You can find some other Yum repo containing PHP 5.2 but I suggest using one from Jason Litka. He has nice, detailed explanation on his blog how to install his Yum repo: http://www.jasonlitka.com/yum-repository/ Yum recommends that you install Yum-Plugin-Priorities when you install any third-party repo.
So you start with the standard Yum installation of PHP 5.1.6 on CentOS 5.2. Then, once you have installed Jason's repo, you can update PHP. If you are using APC with PHP (always a good idea) you need to first disable it and re-install after update:
# pecl uninstall apc
# mv /etc/php.d/apc.ini /tmp/apc.ini
# yum update php
# pecl -d memory_limit=16M install apc
# mv /tmp/apc.ini /etc/php.d/apc.iniThe uninstall/re-install procedure for APC is actually relevant for any other extension you might have installed using PECL for PHP 5.1.6.
If you run into any problems uninstalling PECL just remove the .so file and the configuration that tries to load it. If you run into any problems re-installing APC with PECL, read a great blog post from Frank that explains everything in detail.


i face this problem 0
i face this problem
0 packages excluded due to repository priority protections
Setting up Update Process
Could not find update match for php
No Packages marked for Update
External Repo Misconfigured
Jason Litka's repo must be misconfigured on your server. Did you configure it? It does not look like your yum is using it. If you are using some other third-party yum repo, they probably do not have PHP 5.2
The Centos testing repo has
The Centos testing repo has a newer version of php, specifically v5.2.6.
See here: http://dev.centos.org/centos/5/testing/
Great
Thank you!
P.S. To enable centos-dev, you need to create
/etc/yum.repos.d/centos-test.repo and enter following lines in it:
You can remove Litka's repo from /etc/yum.repos.d if you do that (Jason, currently, has the same 5.2.6 version of PHP, though).
Fantastic! Just got a new
Fantastic! Just got a new VPS with 5.1.6, and this got me to 5.2.6 without any trouble at all.
Great great great!!! simply
Great great great!!! simply great!!!
Many headaches disappeared and drupal is happy :)
Update to PHP by adding CentOS dev repos worked great
i use godaddy VPS and the default repos doesn't have latest PHP and the other method described here did not work for their servers.
but adding the centos-dev repos worked great.
the whole process took about 10 minutes.
thanks to whomever posted that.
Thanks for the info
I installed Apache's shindig and it required PHP 5.2.x. I upgrading with your instructions, they were clear and easy to follow.
Thanks
Gary
centos 5 + plesk + php 5.2
http://www.atomicorp.com/wiki/index.php/PHP
upgrading php to 5.2 on centos 5
the most seamless way to the moment
Thanks, this worked great!
Thanks, this worked great!
It works !
Irakli,
Many many thanks for taking the time to blog this. I am working to a tight deadline and groaned when I realised I needed to update PHP, but your posting led to a painless and quick answer.
Guy.
Sure
You are most welcome. Thank you for your kind feedback.
Problem with sqllite
When I try to update php I get the following message:
Setting up Update Process
Resolving Dependencies
--> Running transaction check
---> Package php.x86_64 0:5.2.6-jason.1 set to be updated
--> Processing Dependency: php-cli = 5.2.6-jason.1 for package: php
--> Processing Dependency: php-common = 5.2.6-jason.1 for package: php
--> Processing Dependency: php <= 5.2.0 for package: php-sqlite2
--> Running transaction check
---> Package php-common.x86_64 0:5.2.6-jason.1 set to be updated
--> Processing Dependency: php <= 5.2.0 for package: php-sqlite2
---> Package php-cli.x86_64 0:5.2.6-jason.1 set to be updated
--> Processing Dependency: php-common = 5.1.6-20.el5_2.1 for package: php-imap
--> Processing Dependency: php-common = 5.1.6-20.el5_2.1 for package: php-mbstring
--> Processing Dependency: php-common = 5.1.6-20.el5_2.1 for package: php-gd
--> Processing Dependency: php-common = 5.1.6-20.el5_2.1 for package: php-xml
--> Processing Dependency: php-common = 5.1.6-20.el5_2.1 for package: php-mysql
--> Processing Dependency: php-common = 5.1.6-20.el5_2.1 for package: php-pdo
--> Running transaction check
---> Package php-mysql.x86_64 0:5.2.6-jason.1 set to be updated
---> Package php-mbstring.x86_64 0:5.2.6-jason.1 set to be updated
---> Package php-imap.x86_64 0:5.2.6-jason.1 set to be updated
--> Processing Dependency: php <= 5.2.0 for package: php-sqlite2
---> Package php-gd.x86_64 0:5.2.6-jason.1 set to be updated
---> Package php-xml.x86_64 0:5.2.6-jason.1 set to be updated
---> Package php-pdo.x86_64 0:5.2.6-jason.1 set to be updated
--> Finished Dependency Resolution
Error: Missing Dependency: php <= 5.2.0 is needed by package php-sqlite2
Can you suggest what I do?
Uninstall
You should uninstall the old version of "php-sqlite2" RPM that you seem to have (use rpm -qa | grep -i sqlite to find its exact name) so it does not get in your way and then try to install newer version from jasonlitka's, centos-dev or rpmforge repos.
Easy Upgrade but running into mcrypt and mhash issues
Nice easy upgrade (I love yum!)
I bounced apache but saw this on startup :
PHP Warning: PHP Startup: mcrypt: Unable to initialize module
Module compiled with module API=20050922, debug=0, thread-safety=0
PHP compiled with module API=20060613, debug=0, thread-safety=0
These options need to match
in Unknown on line 0
PHP Warning: PHP Startup: mhash: Unable to initialize module
Module compiled with module API=20050922, debug=0, thread-safety=0
PHP compiled with module API=20060613, debug=0, thread-safety=0
These options need to match
in Unknown on line 0
I tried to update php-mcrypt
yum -y install php-mcrypt
but it says :
Package php-mcrypt-5.1.6-15.el5.centos.1.x86_64 already installed and latest version
obviously this is the wrong version of mycrypt :)
Any help?
Thanks
mhash and mcrypt issues fixed
After some more searching - I found and fixed the issue.
Posting b/c I hope this helps someone.
First - I used RPM search to see if there were any updated mhash/mcrypt packages out there
http://rpmfind.net/linux/rpm2html/search.php?query=php-mcrypt
http://rpmfind.net/linux/rpm2html/search.php?query=php-mhash
Note the ones that work for you for me - I ran these commands :
wget ftp://rpmfind.net/linux/fedora/updates/7/ppc64/php-mcrypt-5.2.6-2.fc7.pp...
then :
rpm -ivh --nodeps php-mcrypt-5.2.6-2.fc7.ppc64.rpm
then :
wget ftp://rpmfind.net/linux/fedora/updates/7/ppc64/php-mhash-5.2.6-2.fc7.ppc...
then :
rpm -ivh --nodeps php-mhash-5.2.6-2.fc7.ppc64.rpm
Then bounce apache - all seems well for now ;)
Thanks
Thank you for posting the solution, Rob. I've run into the similar problem, too. I suspect the latest rpmforge yum repo has some problems. Can't imagine why there would be a problem when they do have proper RPMs.
Anyway - thanks!
php module issues
Hi,
Upon updating php 5.1 to 5.2 I got this issue.
Anybody had some idea in solving this problem?
Thanks and More power
# php -v
PHP Warning: PHP Startup: ffmpeg: Unable to initialize module
Module compiled with module API=20050922, debug=0, thread-safety=0
PHP compiled with module API=20060613, debug=0, thread-safety=0
These options need to match
in Unknown on line 0
PHP Warning: PHP Startup: imagick: Unable to initialize module
Module compiled with module API=20050922, debug=0, thread-safety=0
PHP compiled with module API=20060613, debug=0, thread-safety=0
These options need to match
in Unknown on line 0
PHP Warning: PHP Startup: mcrypt: Unable to initialize module
Module compiled with module API=20050922, debug=0, thread-safety=0
PHP compiled with module API=20060613, debug=0, thread-safety=0
These options need to match
in Unknown on line 0
PHP Warning: PHP Startup: memcache: Unable to initialize module
Module compiled with module API=20050922, debug=0, thread-safety=0
PHP compiled with module API=20060613, debug=0, thread-safety=0
These options need to match
in Unknown on line 0
PHP Warning: PHP Startup: xslcache: Unable to initialize module
Module compiled with module API=20050922, debug=0, thread-safety=0
PHP compiled with module API=20060613, debug=0, thread-safety=0
These options need to match
in Unknown on line 0
PHP 5.2.9 (cli) (built: Mar 11 2009 08:22:06)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies
Thanks!
This helped me in and solved my problems in about 15 seconds. (Had issues with Zend Framework). I used the testing repo and as of today it currently has php 5.2.9 and so far all looks good.
These are the only package I have installed:
Updating:
php x86_64 5.2.9-2.el5.centos c5-testing 1.2 M
php-cli x86_64 5.2.9-2.el5.centos c5-testing 2.4 M
php-common x86_64 5.2.9-2.el5.centos c5-testing 238 k
Updating for dependencies:
php-gd x86_64 5.2.9-2.el5.centos c5-testing 114 k
php-mysql x86_64 5.2.9-2.el5.centos c5-testing 83 k
php-pdo x86_64 5.2.9-2.el5.centos c5-testing 63 k
php-xml x86_64 5.2.9-2.el5.centos c5-testing 103 k
Thanks
Install Issues
With further inspection I do actually have issues as mentioned by Rob V above.
[27-Jul-2009 22:02:42] PHP Warning: PHP Startup: mcrypt: Unable to initialize module
Module compiled with module API=20050922, debug=0, thread-safety=0
PHP compiled with module API=20060613, debug=0, thread-safety=0
These options need to match
in Unknown on line 0
[27-Jul-2009 22:02:42] PHP Warning: PHP Startup: memcache: Unable to initialize module
Module compiled with module API=20050922, debug=0, thread-safety=0
PHP compiled with module API=20060613, debug=0, thread-safety=0
These options need to match
in Unknown on line 0
[27-Jul-2009 22:02:42] PHP Warning: PHP Startup: mhash: Unable to initialize module
Module compiled with module API=20050922, debug=0, thread-safety=0
PHP compiled with module API=20060613, debug=0, thread-safety=0
These options need to match
in Unknown on line 0
[27-Jul-2009 22:10:34] PHP Warning: PHP Startup: memcache: Unable to initialize module
Module compiled with module API=20050922, debug=0, thread-safety=0
PHP compiled with module API=20060613, debug=0, thread-safety=0
These options need to match
in Unknown on line 0
My fix was just to comment out the included modules
(mcrypt, mhash, and memcache)
Look in /etc/php.d/*.ini
Solution
Rob has posted a solution for this problem, further up the comment queue: http://www.freshblurbs.com/install-php-5-2-centos-5-2-using-yum#comment-...
Update to PHP by adding CentOS dev repos worked great
i use godaddy VPS and the default repos doesn't have latest PHP and the other method described here did not work for their servers.
but adding the centos-dev repos worked great.
the whole process took about 10 minutes.
thanks to whomever posted that.
Excellent!
That was perfect! Thank you! I'm just coming up to speed with Linux so it's good to learn how to add a repo along with using yum to upgrade applications.
Thanks so much for this writeup! You also got me using nano instead of "vi".
Thanks a lot for this useful
Thanks a lot for this useful post, the info is pretty good and the desciption very adecuate. Keep the good work.
aumento seno
Thank you
Gamar joba, bidjo...
Thank you very much for your detailed tutorial.
Looked four hours for this information
I was familiar with the steps but could not find a repo with 5.2. Thank you for saving me more headaches.