How to build missing PHP 5.3 extensions on CentOS 5.6

I've created a fresh installation of CentOS 5.6, and installed PHP 5.3 using the php53-* packages from the CentOS repository. Specifically, I've got:

  • php53
  • php53-cli
  • php53-common
  • php53-devel
  • php53-mysql
  • php53-pdo
  • php53-xml

However, I also need to install the mcrypt and apc extensions for my application. CentOS has a pre-built php-mcrypt package, but there is no equivalent php53-mcrypt. The installation of APC requires pecl which I would normally install (for 5.1) with the php-pear package, but likewise there doesn't seem to be a php53-pear package.

How do I build these?

 

You can compile and install manually only the mcrypt extension. This is what I did in my CentOS 5.6 VPS:

First install some required packages:

yum install php53-devel libmcrypt-devel gcc gcc-c++

Then download the php 5.3.6 source code from php.net and unpack it:

wget http://mx2.php.net/get/php-5.3.6.tar.bz2/from/us3.php.net/mirror
tar xvjf php-5.3.6.tar.bz2

(Please note that the download link will change with every subsequent PHP release.)

Go to the directory with the mcrypt extension source code and compile:

cd php-5.3.6/ext/mcrypt/
phpize
aclocal
./configure
make

Then install:

make install

Create the configuration file for PHP /etc/php.d/mcrypt.ini containing:

extension=mcrypt.so

Restart apache:

/etc/init.d/httpd restart

Create a file with phpinfo just to check if the extension was loaded:

<?php
phpinfo();
?>
posted @ 2013-07-18 15:39  cav5lier  阅读(300)  评论(0编辑  收藏  举报