Since I couldn’t 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 didn’t want people going to broken pages as I did these updates:
[user@server ~]$ sudo service httpd stop
Stopping httpd: [ OK ]
[user@server ~]$
Next, I remove the old PHP packages:
[user@server ~]$ sudo yum remove php php-cli php-common php-devel php-gd php-mbstring \
php-mysql php-mcrypt php-pdo php-pear php-pgsql php-xml php-xmlrpc
Loaded plugins: fastestmirror, priorities
Setting up Remove Process
Resolving Dependencies
–> Running transaction check
—> Package php.x86_64 0:5.2.16-jason.1 set to be erased
…
Remove 13 Package(s)
Reinstall 0 Package(s)
Downgrade 0 Package(s)
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
…
Complete!
[user@server ~]$
Finally, I installed the available replacement packages:
[user@server ~]$ sudo yum install php53 php53-cli php53-common php53-devel php53-gd \
php53-mbstring php53-mysql php53-pdo php53-pgsql php53-xml php53-xmlrpc
Loaded plugins: fastestmirror, priorities
Loading mirror speeds from cached hostfile
* base: centos.mirror.lstn.net
* epel: fedora-epel.mirror.lstn.net
* extras: mirror.ubiquityservers.com
* updates: mirror.steadfast.net
Setting up Install Process
…
Install 2 Package(s)
Upgrade 0 Package(s)
Total download size: 18.5 M
Is this ok [y/N]: y
Downloading Packages:
…
Complete!
[user@server ~]$
Now it’s time to get the other PHP elements that were not available as packages.
Install PHP mcrypt
The php53-mcrypt package wasn’t available, so we have to install it manually. The following steps will accomplish this.
We first need to install the development package for mcrypt:
[user@server ~]$ sudo yum install php53-devel libmcrypt-devel
PHP’s 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://museum.php.net/php5/php-5.3.3.tar.gz
–2011-12-07 14:32:00– http://museum.php.net/php5/php-5.3.3.tar.gz
Resolving museum.php.net… 67.23.255.166
Connecting to museum.php.net|67.23.255.166|: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 2.04M/s in 6.6s
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 ~]$
Now we need to compile and install the mcrypt extension:
[user@server ~]$ cd php-5.3.3/ext/mcrypt/
[user@server mcrypt]$ phpize
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]$
Install PHP Pear
Finally, I need to install PHP Pear. If you haven’t used it, it is essentially a code repository tool for easily installing, upgrading, and managing hosted code. It is basically PHP’s version of Perl’s CPAN.
Installing this is fairly straightforward.
[user@server ~]$ wget http://pear.php.net/go-pear.phar
–2011-06-24 15:18:22– http://pear.php.net/go-pear.phar
Resolving pear.php.net… 78.129.214.25
Connecting to pear.php.net|78.129.214.25|:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: 3680148 (3.5M) [application/octet-stream]
Saving to: `go-pear.phar’
100%[===============================================================>] 3,680,148 523K/s in 7.3s
2011-06-24 15:18:29 (491 KB/s) – `go-pear.phar’ saved [3680148/3680148]
FINISHED –2011-06-24 15:18:29–
Downloaded: 1 files, 3.5M in 7.3s (491 KB/s)
[user@server ~]$ sudo php go-pear.phar
Below is a suggested file layout for your new PEAR installation. To
change individual locations, type the number in front of the
directory. Type ‘all’ to change all of them or simply press Enter to
accept these locations.
Beginning install…
PHP Warning: date(): It is not safe to rely on the system’s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected ‘America/Chicago’ for ‘CDT/-5.0/DST’ instead in phar:///usr/src/go-pear.phar/PEAR/Registry.php on line 1012
PHP Warning: date(): It is not safe to rely on the system’s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected ‘America/Chicago’ for ‘CDT/-5.0/DST’ instead in phar:///usr/src/go-pear.phar/PEAR/Registry.php on line 1012
PHP Warning: date(): It is not safe to rely on the system’s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected ‘America/Chicago’ for ‘CDT/-5.0/DST’ instead in phar:///usr/src/go-pear.phar/PEAR/Registry.php on line 1012
PHP Warning: date(): It is not safe to rely on the system’s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected ‘America/Chicago’ for ‘CDT/-5.0/DST’ instead in phar:///usr/src/go-pear.phar/PEAR/Registry.php on line 1012
Configuration written to /etc/pear.conf…
Initialized registry…
…
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. It’s PHP 5.3-specific. I posted how to fix it here.