Beruflich Dokumente
Kultur Dokumente
http://chrisjean.com/2011/06/24/upgrade-php-5-1-or-5-2-to-5-3-on-centos/
Chris Jean Linux, WordPress, programming, anime, and other stuff Home Linux Development Random Ramblings
Total download size: 309 M Is this ok [y/N]: y Downloading Packages: (1/213): avahi-glib-0.6.16-10.el5_6.x86_64.rpm (2/213): avahi-glib-0.6.16-10.el5_6.i386.rpm (3/213): rng-utils-2.0-4.el5.x86_64.rpm ... Complete! [user@server ~]$
Notice the white y toward the bottom. Before it does anything, you must answer its question with a y. Just hitting enter will cancel the upgrade. This will take between 5-30 minutes on average depending on the number of packages to be upgraded, the speed of your system, and your servers connection speed. So pop open a root beer and wait for everything to finish up.
1 of 8
24-10-2011 13:48
http://chrisjean.com/2011/06/24/upgrade-php-5-1-or-5-2-to-5-3-on-centos/
Since this should have installed a new kernel for your system, you will want to reboot so that this new kernel can be loaded. Rebooting a server can be a scary thing. Make sure that you know how to contact your hosting companys tech support in case there are any problems with connecting to the server after the reboot. Also make sure that you notify any people that may be upset about the reboot before you do it.
This version of CentOS took the odd step of having both PHP 5.2 and PHP 5.3 packages. The main packages are 5.2 while another set with modified names are 5.3. For instance, the PHP 5.2 main package is php while the PHP 5.3 one is php53. I still have no idea why they decided to do things this way, but I guess it has to do with some software not supporting 5.3 properly yet. Since I couldnt just install the php53 packages as they would conflict with the php packages, I had to remove all the existing PHP packages and install the new ones. This meant that I had to take stock of exactly what packages I had to remove and replace. I used the yum commands list command to quickly get this information:
[user@server ~]$ yum list installed | grep php | cut -d' ' -f1 php.x86_64 php-cli.x86_64 php-common.x86_64 php-devel.x86_64 php-gd.x86_64 php-mbstring.x86_64 php-mysql.x86_64 php-mcrypt.x86_64 php-pdo.x86_64 php-pear.noarch php-pgsql.x86_64 php-xml.x86_64 php-xmlrpc.x86_64 [user@server ~]$
The | cut -d' ' -f1 part at the end is just some fanciness to show only the package name and not the extra cruft. Next I checked to make sure that those packages were available for php53:
[user@server ~]$ yum search php53 | cut -d' ' -f1 | grep php php53.x86_64 php53-bcmath.x86_64 php53-cli.x86_64 php53-common.x86_64 php53-dba.x86_64 php53-devel.x86_64 php53-gd.x86_64 php53-imap.x86_64 php53-intl.x86_64 php53-ldap.x86_64 php53-mbstring.x86_64 php53-mysql.x86_64 php53-odbc.x86_64 php53-pdo.x86_64 php53-pgsql.x86_64 php53-process.x86_64 php53-pspell.x86_64 php53-snmp.x86_64 php53-soap.x86_64 php53-xml.x86_64 php53-xmlrpc.x86_64 [use@server ~]$
I quickly noticed that neither php53-mcrypt.x86_64 nor php53-pear.noarch were available. I would have to install these manually. First, I shut down the Apache server as I didnt want people going to broken pages as I did these updates:
[user@server ~]$ sudo service httpd stop Stopping httpd: [user@server ~]$ [ OK ]
2 of 8
24-10-2011 13:48
http://chrisjean.com/2011/06/24/upgrade-php-5-1-or-5-2-to-5-3-on-centos/
Resolving Dependencies --> Running transaction check ---> Package php.x86_64 0:5.2.16-jason.1 set to be erased ... Remove Reinstall Downgrade 13 Package(s) 0 Package(s) 0 Package(s)
Is this ok [y/N]: y Downloading Packages: Running rpm_check_debug Running Transaction Test ... Complete! [user@server ~]$
Total download size: 18.5 M Is this ok [y/N]: y Downloading Packages: ... Complete! [user@server ~]$
Now its time to get the other PHP elements that were not available as packages.
PHPs mcrypt extension can be compiled and installed from the source code, so we need to download and unpackage the PHP 5.3.3 source. You can find a download link on the PHP releases page. I used wget to make the process a bit quicker:
[user@server ~]$ wget http://us2.php.net/get/php-5.3.3.tar.gz/from/us.php.net/mirror --2011-06-24 19:10:34-- http://us2.php.net/get/php-5.3.3.tar.gz/from/us.php.net/mirror Resolving us2.php.net... 64.71.164.5, 2001:470:0:b9::4047:a405 Connecting to us2.php.net|64.71.164.5|:80... connected. HTTP request sent, awaiting response... 302 Found Location: http://us.php.net/distributions/php-5.3.3.tar.gz [following] --2011-06-24 19:10:34-- http://us.php.net/distributions/php-5.3.3.tar.gz Resolving us.php.net... 208.69.120.58 Connecting to us.php.net|208.69.120.58|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 13921529 (13M) [application/x-gzip] Saving to: `php-5.3.3.tar.gz' 100%[=============================================================>] 13,921,529 2011-06-24 19:10:40 (2.00 MB/s) - `php-5.3.3.tar.gz' saved [13921529/13921529] [user@server ~]$ tar xf php-5.3.3.tar.gz [user@server ~]$ 2.04M/s in 6.6s
3 of 8
24-10-2011 13:48
http://chrisjean.com/2011/06/24/upgrade-php-5-1-or-5-2-to-5-3-on-centos/
Configuring for: PHP Api Version: 20090626 Zend Module Api No: 20090626 Zend Extension Api No: 220090626 [user@server mcrypt]$ aclocal [user@server mcrypt]$ ./configure checking for egrep... grep -E checking for a sed that does not truncate output... /bin/sed checking for cc... cc ... checking how to hardcode library paths into programs... immediate configure: creating ./config.status config.status: creating config.h [user@server mcrypt]$ make .... Build complete. Don't forget to run 'make test'. [user@server mcrypt]$ make test Build complete. Don't forget to run 'make test'. ===================================================================== PHP : /usr/bin/php PHP_SAPI : cli PHP_VERSION : 5.3.3 ZEND_VERSION: 2.3.0 ... Do you want to send this report now? [Yns]: y Please enter your email address. (Your address will be mangled so that it will not go out on any mailinglist in plain text): user@example.com Posting to qa.php.net /buildtest-process.php Thank you for helping to make PHP better. [user@server mcrypt]$ sudo make install Installing shared extensions: /usr/lib64/php/modules/ [user@server mcrypt]$
Now all we have to do is set up the mcrypt.ini file so that the mcrypt extension loads with PHP. This file needs to reside at /etc/php.d/mcrypt.ini.
[user@server mcrypt]$ echo -e "; Enable mcrypt extension module\nextension=mcrypt.so" | \ sudo tee /etc/php.d/mcrypt.ini ; Enable mcrypt extension module extension=mcrypt.so [user@server mcrypt]$
4 of 8
24-10-2011 13:48
http://chrisjean.com/2011/06/24/upgrade-php-5-1-or-5-2-to-5-3-on-centos/
Beginning install... PHP Warning: date(): It PHP Warning: date(): It PHP Warning: date(): It PHP Warning: date(): It Configuration written to Initialized registry... ...
is not safe to rely is not safe to rely is not safe to rely is not safe to rely /etc/pear.conf...
on on on on
to to to to
or or or or
PEAR: Optional feature gtk2installer available (PEAR's PHP-GTK2-based installer) PEAR: To install optional features use "pear install pear/PEAR#featurename" The 'pear' command is now at your service at /usr/bin/pear [user@server ~]$
Notice that ugly mess about the date() function. Its PHP 5.3-specific. I posted how to fix it here.
Final Thoughts
All in all, this was much more complex than I had anticipated. I can understand why the CentOS devs had decided to make a separate set of packages for PHP 5.3, but it really has made things difficult. I do have to warn you that many other packages will start to take issue with this setup as they will have dependency requirements for the php package which naturally conflicts with the php53. This leads me to think that they have done this in a way that the repo was not supposed to support as the dependencies should not break in this fashion. Oh well. Nothing is perfect. Categories : Linux, Tips 'n Tricks
Comments
1. Guillermo says: July 2, 2011 at 5:25 am Thanks a lot, Chris you saved me a weekend of frustration! I had PHP 5.3 installed but had some problems with mcrypt: [code] Errors loading the mcrypt module with CentOS. php53-common-5.3.3-1.el5_6.1.x86_64 from installed has depsolving problems --> php53-common conflicts with php-common [/code] Full log @ http://pastebin.com/KhV4NVRh After some research I found out that others also had the same bug where php53-common conflicts with php-common, as described in http://euniv.appspot.com/gadget/centos-56-how-to-resolve-php53-rpm-dependency-conflict-with-phpmcrypt-and-phpcommon/ So it seems this tutorial fixes the issue. I did everything pretty much step by step and it worked really well! Thanks a lot Reply 2. M-squared says: July 5, 2011 at 3:15 am Chris, thanks so much for this very clear guide to upgrading php on CentOS! Ive upgraded our server to CentOS 5.6, checked the php packages that have to be removed (version 5.1.6) and seen that the php53 files are indeed there but now my courage is failing me. I see you are using WordPress did you have any difficulties with your WP site(s) after you did the php ugrade? I run a WP site for my organization and would like to update to WP 3.2. But our CentOS server is running php 5.1.6, and the WP upgrade requires 5.2.4 or higher. So I really want to follow through on your procedures, but Im afraid Ill crash the site. If I mess up, how would I restore php 5.1.6? (As you can tell, Im a novice)
5 of 8
24-10-2011 13:48
http://chrisjean.com/2011/06/24/upgrade-php-5-1-or-5-2-to-5-3-on-centos/
Reply Chris Jean says: July 5, 2011 at 8:53 am The new packages are not really any different from the regular ones other than the version of PHP that they provide. The reason that there are so many steps is that software version upgrades are not meant to work this way. The distro is supposed to bless specific versions of packages and release those together. Since some of the packages had issues with PHP 5.3, they opted to do this weird work around which is far from ideal. The better solution, IMHO, would have been to work with the developers of the problem packages and get them to upgrade their software so that the conflict did not exist. However, that didnt happen, so back to reality. The WordPress sites running on the server I did this on had no issues after the upgrades, so this will not be an issue. Now whether or not you will have some specific packages on your server that may take issue with this upgrade path, I cant say. If you have issues, you can simply reverse the process by first removing the php53* packages and then reinstalling the needed php* packages. Reply 3. phpgeek says: July 6, 2011 at 12:16 am thanks very much. this is working very well for me. Reply 4. nick says: July 8, 2011 at 12:29 am thank you for making this so easy, i did it in about 20 minutes with beer in hand. cheers! Reply 5. Nate says: July 14, 2011 at 2:45 pm Hi Chris, Thanks so much for this article. Saved a fair amount of time. Take care, -Nate Reply 6. Brian Katzung says: July 28, 2011 at 3:40 pm Thank you Chris. This was extremely helpful. Reply 7. Mark Johns says: July 29, 2011 at 8:20 am Hi Chris Thanks for the amazingly accurate and well put documentation. This really helped us. All the best Mark Reply 8. El bloc personal de jjberdullas | Com installar els paquets estndard de PHP 5.x.x a CentOS 5.x says: August 7, 2011 at 3:46 pm [...] Actualitzat 24/6/2011: si necessites fer servir la versi 5.3 de PHP consulta el segent link: http://chrisjean.com/2011/06/24/upgrade-php-5-1or-5-2-to-5-3-on-centos/ Com ja ha quedat pals, jo utilitzo sovint la distribuci CentOS. El problema [...] Reply 9. php 5.3.6 in Centos 5.6 with the NECESSARY MODULES enriquemanuel says: August 12, 2011 at 3:52 pm [...] as another blogger / poster mentioned you are missing some major components like mcrypt (hey, if you didnt notice no big issue, [...]
6 of 8
24-10-2011 13:48
http://chrisjean.com/2011/06/24/upgrade-php-5-1-or-5-2-to-5-3-on-centos/
Reply 10. Alex says: August 12, 2011 at 11:21 pm Chris, I have WHM/cPanel server with tons of domains. Everything is working fine until I upgraded the PHP to 5.3. Now my customers complaning as websites showing with ?????(such symblos) but this issue for few domains only. Can you please let me know is there anything I can do to resolve this issue? Thanks for providing best article. Reply Chris Jean says: August 15, 2011 at 1:06 pm Sorry, but I dont think thats enough information for me to know what is going on. My best guess is that there is some issue with recognizing UTF-8 or Unicode characters. I cant know what might be the source of this with the information given. Reply 11. Adam says: August 24, 2011 at 5:01 pm Chris, Thanks, I was looking for this solution all day, and thought I would have to download RPMs for some shady websites This worked perfectly for me on CentOS Linux version 5.6, PHP 5.1.6. No problems with mysql or wordpress. Reply 12. daniel says: August 30, 2011 at 3:01 am thanks alot! i was going crazy you helped me Reply 13. Kamran says: September 1, 2011 at 5:37 am Thanks Chris, It saved me trouble I was having upgrading to php 5.3; Though I could find php53-mcrypt in my repository, I still had to install pear manually. Reply 14. Mat says: September 21, 2011 at 3:52 pm Thanks a lot! This is exactly what I was looking for. Reply 15. zbyszek says: October 17, 2011 at 2:44 pm I want to add mcrypt, but arter aclocal I have: configure.in:8: warning: LT_AC_PROG_SED is m4_required but is not m4_defund configure.in:8: LT_AC_PROG_SED is required by acinclude.m4:2683: PHP_CONFIG_NICE is expanded from configure.in:8: the top level
7 of 8
24-10-2011 13:48
http://chrisjean.com/2011/06/24/upgrade-php-5-1-or-5-2-to-5-3-on-centos/
What should I do? Reply Chris Jean says: October 17, 2011 at 3:36 pm After a bit of digging, it seems to be a problem with the locations of your systems ltmain.sh and libtool.m4 files. Read this Reply
Leave a Reply
Name (required) Mail (will not be published) (required) Website
Notify me of followup comments via e-mail Chris Jean Copyright 2011 All Rights Reserved iThemes Builder by iThemes Powered by WordPress
8 of 8
24-10-2011 13:48