环境说明:

操作系统:CentOS 5.11 x86_64

php版本:php 5.3.3(yum方式安装)


原来php安装过程:

1
yum -y  install  httpd php53 php53-bcmath php53-cli php53-common php53-dba php53-devel php53-gd php53-mbstring php53-xml php53-xmlrpc php53-snmp php53-mysql


现在因为项目原因需要安装libevent及pcntl和php-mcrypt,php-mcrypt的安装过程见

http://fengwan.blog.51cto.com/508652/1661548


1.php5.3.3安装libevent

1
2
3
4
5
6
7
8
9
10
11
12
13
yum -y  install  libevent-devel
wget 
tar  xf  libevent-0.1.0.tgz
cd  libevent-0.1.0
/usr/bin/phpize
. /configure  -- enable -libevent --with-php-config= /usr/bin/php-config
make
make  install
#之后就能见到
[root@CentOS5 libevent-0.1.0] # make install
Installing shared extensions:      /usr/lib64/php/modules/
 
echo  'extension=libevent.so' > /etc/php .d /libevent .ini

如果只安装libevent就足够的话,这个时候重新启动httpd服务即可

1
2
[root@CentOS5 ~] # php -m |grep libevent
libevent

下面是phpinfo()里的模块信息

wKioL1Wonp6xnHX4AACoiFRKgMk022.jpg


2.php 5.3.3安装pcntl

pcntl目前存在于php-5.3.3.tar.gz的源码中,需要我们去官网下载源码。

1
2
3
4
5
6
7
8
9
10
11
wget http: //museum .php.net /php5/php-5 .3.3. tar .gz
 
cd  php-5.3.3 /ext/pcntl
/usr/bin/phpize
. /configure  -- enable -pcntl --with-php-config= /usr/bin/php-config
make
make  install
echo  'extension=pcntl.so'  > /etc/php .d /pcntl .ini
#重新启动httpd
[root@CentOS5 ~] # php -m |grep pcntl
pcntl


如果在运行php -m |grep pcntl的时候出现

1
PHP Warning:  Module  'pcntl'  already loaded  in  Unknown on line 0

则可能是出现了重复加载pcntl的情况,则将刚才的/etc/php.d/pcntl.ini删除,重新启动即可。



3.php 5.3.3安装phar并下载phpunit作为测试工具

1
2
3
4
5
6
7
8
9
wget http: //museum .php.net /php5/php-5 .3.3. tar .gz
yum -y  install  pcre-devel   
#phar需要使用pcre模块
cd  php-5.3.3 /ext/phar
/usr/bin/phpize
. /configure  -- enable -phar --with-php-config= /usr/bin/php-config
make
make  install
echo  'extension=phar.so'  > /etc/php .d /phar .ini

如果你安装suhosin模块,则需要

修改/etc/php.d/suhosin.ini这行为

1
suhosin.executor.include.whitelist = phar

如果有设置php.ini的open_basedir则需要注释掉,防止出现各种问题

下载phpunit

1
2
3
4
5
wget https: //phar .phpunit.de /phpunit .phar
chmod  +x phpunit.phar
mv  phpunit.phar  /usr/local/bin/phpunit
phpunit --version
PHPUnit 4.7.7 by Sebastian Bergmann and contributors.