Skip to content


phpize不重新编译PHP实现扩展的安装

当php已经编译好在运行,又不想停机重新编译时可用此方法增加扩展。
增加自已写的库也可用此方法,参考HonestQiao 的记录
http://chinaunix.net/jh/27/547568.html

php之前的编译环境
增加运行phpmsnclass需mhas和pcntl库为例

1.先下载类库
cd /home/c1g/src/

wget http://blog.s135.com/soft/linux/nginx_php/mcrypt/libmcrypt-2.5.8.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/mhash/mhash-0.9.9.9.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/mcrypt/mcrypt-2.6.8.tar.gz

2.编译安装类库

tar zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8/
./configure
make
make install
/sbin/ldconfig
cd libltdl/
./configure –enable-ltdl-install
make
make install
cd ../../

tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9/
./configure
make
make install
cd ../

ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1

tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
/sbin/ldconfig
./configure
make
make install
cd ../

3.开始编译安装mhash扩展
进入php原始编译目录

cd /home/c1g/src/php-5.2.6/ext/mhash
/opt/php/bin/phpize
#会有以下信息生成,并产生编译文件
#Configuring for:
#PHP Api Version: 20041225
#Zend Module Api No: 20060613
#Zend Extension Api No: 220060519
./configure –with-php-config=/opt/php/bin/php-config
make
make install

生成的mhash.so会存下以下目录
Installing shared extensions: /opt/php/lib/php/extensions/no-debug-non-zts-20060613/

4.安装pcntl

cd ../pcntl
/opt/php/bin/phpize
./configure –with-php-config=/opt/php/bin/php-config
make
make install

生成的pcntl.so会存下以下目录
Installing shared extensions: /opt/php/lib/php/extensions/no-debug-non-zts-20060613/

5.编辑php.ini,指定好扩展的目录和需加载的库

extension_dir = “/opt/php/lib/php/extensions/no-debug-non-zts-20060613/”

extension=”mhash.so”
extension=”pcntl.so”

6.重新reload一下php

7.检查下是否已生效
/opt/php/bin/php -m

[PHP Modules]
bcmath
ctype
curl
date
dom
filter
gd
hash
iconv
json
libxml
mbstring
mcrypt
memcache
mhash
mysql
mysqli
pcntl
pcre
PDO
pdo_sqlite
posix
Reflection
session
shmop
SimpleXML
SPL
SQLite
standard
sysvsem
tokenizer
XCache
xml
xmlreader
xmlwriter
zlib

[Zend Modules]
XCache

参考:
http://blog.s135.com/nginx_php_v5/
http://blog.csdn.net/sdomain/archive/2009/09/04/4520425.aspx

Posted in PHP, 技术.

Tagged with , , .


One Response

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. 奶茶 says

    您真厲害!!!!!
    實在太感恩您的指導



Some HTML is OK

or, reply to this post via trackback.