Professional Documents
Culture Documents
Howtos - PHP 5.1 To 5
Howtos - PHP 5.1 To 5
Howtos - PHP 5.1 To 5
2 - CentOS Wiki
http://wiki.centos.org/HowTos/PHP_5.1_To_5.2
WARNING: php version 5.2.6, as described later in this document is obsolete and prone to security issues. Please consider either upgrading to php53 as included in CentOS 5.6 or use the IUS Community Repo
Contents 1. 2. 3. 4. 5. Summary Add the development repositories Update PHP packages Conclusion Extras 1. Updating/Installing mcrypt 2. JSON and PDO being loaded twice
Summary
This guide describes how to upgrade the standard PHP 5.1.x packages in CentOS 5.x 32-bit to the current development versions 5.2.x. These instructions were created using CentOS 5.3 32-bit and with the following PHP packages installed:
# rpm -qa |grep php php-common-5.1.6-15.el5.i386 php-cli-5.1.6-15.el5.i386 php-5.1.6-15.el5.i386 php-pdo-5.1.6-15.el5.i386 php-bcmath-5.1.6-15.el5.i386 php-ldap-5.1.6-15.el5.i386 php-devel-5.1.6-15.el5.i386 php-gd-5.1.6-15.el5.i386 php-xml-5.1.6-15.el5.i386 php-mbstring-5.1.6-15.el5.i386 php-mysql-5.1.6-15.el5.i386 php-dba-5.1.6-15.el5.i386
As long as you're using the standard PHP packages on your CentOS server you won't need to do anything extra. If you're using extra PHP packages that aren't part of the standard CentOS repositories (like php-mcrypt) you'll have to remove them or find updated versions of them.
1 of 4
21-Jul-11 10:53 PM
http://wiki.centos.org/HowTos/PHP_5.1_To_5.2
# /etc/yum.repos.d/CentOS-Testing.repo
Make sure to remove any spaces at the start of each line, then save and close the file and you're done.
Now you can use yum to update the PHP packages on your system:
# yum update
You should be shown a list of packages that are going to be updated. Compare it to the list of PHP packages on your system. Note any packages that are not in the list. You'll need to remove these packages or find updates for them because they won't work after you update to PHP 5.2.x. If that is acceptable type "y" to continue and let yum update the packages. Once yum has completed restart Apache:
# service httpd restart
To verify the update is working create a simple testing.php in your www directory with the following source code:
<?php phpinfo(); ?>
2 of 4
21-Jul-11 10:53 PM
http://wiki.centos.org/HowTos/PHP_5.1_To_5.2
and open it in a web browser. The new PHP version should be reflected at the top of the page.
Conclusion
You should now have PHP 5.2.6 running on CentOS 5.3 32-bit.
# rpm -qa |grep php php-cli-5.2.6-2.el5s2 php-mbstring-5.2.6-2.el5s2 php-devel-5.2.6-2.el5s2 php-pdo-5.2.6-2.el5s2 php-gd-5.2.6-2.el5s2 php-dba-5.2.6-2.el5s2 php-common-5.2.6-2.el5s2 php-bcmath-5.2.6-2.el5s2 php-xml-5.2.6-2.el5s2 php-pear-1.5.1-2.el5s2 php-ldap-5.2.6-2.el5s2 php-5.2.6-2.el5s2 php-mysql-5.2.6-2.el5s2 # php -v PHP 5.2.6 (cli) (built: Sep 15 2008 20:42:05) Copyright (c) 1997-2008 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
Note: If your "php -v" output returns errors about PDO or JSON click here
Extras
Updating/Installing mcrypt
If you have php-mcrypt for PHP 5.1.x installed you'll want to remove it: Note: Your version number maybe different. Alter below command accordingly.
rpm -e php-mcrypt-5.1.6-15.el5.centos.1
Download php-mcrypt for PHP 5.2.x and install it. You can find a 32-bit php-mcrypt package here FedoraJunkies. Note: You'll notice the "--nodeps" flag in the example. When you try to install php-mcrypt without it you get an error that php-common-5.2.6-2.el5s2 is missing even though it is installed.
wget -c http://sourcemirrors.org/scotth/centos/5/php/php-mcrypt5.2.6-2.i386.rpm rpm -i --nodeps php-mcrypt-5.2.6-2.i386.rpm
Restart Apache and you should now see mcrypt information on your testing.php page.
3 of 4
21-Jul-11 10:53 PM
http://wiki.centos.org/HowTos/PHP_5.1_To_5.2
Comment out these lines by adding a ";" in front of "extension=". These two modules are already loaded via these two files:
/etc/php.d/json.ini /etc/php.d/pdo.ini
4 of 4
21-Jul-11 10:53 PM