Skip to content

Installing and upgrading to PHP 5.2 on CentOS and RedHat Linux 5.3 x86_64

phpcentosThis Linux installing guide will walk you through installing PHP 5.2 (Supports the Kohana Framework) with APC, Memcached, ImageMagick and FFmpeg with AMR (3gp support) on CentOS and RHEL

note: This upgrade also repairs the error

"Warning: preg_match(): Compilation failed: support for \P, \p, and \X has not been compiled at offset 2 in file: /var/www/kohana_2.3.1/system/core/utf8.php on line: 65"

Preliminary Note:

I am using a CentOS 5.2 x86_64 server with the RPM Forge YUM repo enabled in this tutorial:

  • server1.example.co.za (IP 10.0.0.100)

House Keeping

Edit yum.conf and add the ‘exclude’ switch to the configuration and this will eliminate 32bit RPM’s from being installed. You can however ignore this step if you’re installing on a 32bit CentOS or RHEL system.

# vi /etc/yum.conf
[main]
exclude=*.i386 *.i586 *.i686
# yum remove openssl.i686 glibc.i686

If you haven’t installed the EPEL, IUS and RPMForge CentOS and RHEL repository, here’s how:

Install the EPEL i386 YUM Repository

# rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm

Install the RPMForge i386 YUM Repository

# rpm -Uvh http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.5.2-2.el5.rf.i386.rpm

Install the IUS i386 YUM Repository

# rpm -Uvh http://dl.iuscommunity.org/pub/ius/stable/Redhat/5/i386/ius-release-1.0-10.ius.el5.noarch.rpm

Next we install the various packages that will be required for our PHP Linux installation

# yum install php52-pear php52 php52-cli php52-common php52-devel php52-gd php52-mbstring php52-mcrypt php52-mysql php52-pdo php52-soap php52-xml php52-xmlrpc php52-bcmath php52-pecl-apc php52-pecl-memcache
# yum install ImageMagick ImageMagick-devel memcached zlib-devel php-pear httpd-devel gcc mysql-devel libxslt-devel re2c ffmpeg ffmpeg-devel lame amrnd
# chkconfig memcached on

NB. Don’t forget to read through the installing guide for FFmpeg with AMR support before continuing.

PECL install the relevant .so modules required by PHP

# pecl install memcache

# pecl install apc

# pecl install PDO

# pecl install pdo_mysql

# pecl install imagick

# pecl install xslcache

and download the source and install the .so files not available via PECL

# wget http://garr.dl.sourceforge.net/sourceforge/ffmpeg-php/ffmpeg-php-0.6.0.tbz2
# tar -xjf ffmpeg-php-0.6.0.tbz2
# cd ffmpeg-php-0.6.0
# phpize
# ./configure
# make
# make install

Create inclusion files for all the .so modules

# echo "extension=xslcache.so" > /etc/php.d/xslcache.ini

# echo "extension=apc.so" > /etc/php.d/apc.ini

# echo "extension=pdo.so" > /etc/php.d/pdo.ini

# echo "extension=pdo_mysql.so" > /etc/php.d/pdo_mysql.ini

# echo "extension=memcache.so" > /etc/php.d/memcache.ini

# echo "extension=mcrypt.so" > /etc/php.d/mcrypt.ini

# echo "extension=imagick.so" > /etc/php.d/imagick.ini

# echo "extension=ffmpeg.so" > /etc/php.d/ffmpeg.ini
# vi /var/www/html/phpinfo.php
<?php

// Show all information, defaults to INFO_ALL
phpinfo();

// Show just the module information.
// phpinfo(8) yields identical results.
phpinfo(INFO_MODULES);

?>

Restart httpd/apache and point your browser at http://your-web-server/phpinfo.php and confirm your installation.