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.编译安装类库

  1. tar zxvf libmcrypt-2.5.8.tar.gz
  2. cd libmcrypt-2.5.8/
  3. ./configure
  4. make
  5. make install
  6. /sbin/ldconfig
  7. cd libltdl/
  8. ./configure --enable-ltdl-install
  9. make
  10. make install
  11. cd ../../
  12.  
  13. tar zxvf mhash-0.9.9.9.tar.gz
  14. cd mhash-0.9.9.9/
  15. ./configure
  16. make
  17. make install
  18. cd ../
  19.  
  20. ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
  21. ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
  22. ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
  23. ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
  24. ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
  25. ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
  26. ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
  27. ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
  28. ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1
  29.  
  30. tar zxvf mcrypt-2.6.8.tar.gz
  31. cd mcrypt-2.6.8/
  32. /sbin/ldconfig
  33. ./configure
  34. make
  35. make install
  36. cd ../

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

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

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

4.安装pcntl

  1. cd ../pcntl
  2. /opt/php/bin/phpize
  3. ./configure --with-php-config=/opt/php/bin/php-config
  4. make
  5. make install

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

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

  1. extension_dir = "/opt/php/lib/php/extensions/no-debug-non-zts-20060613/"
  2.  
  3. extension="mhash.so"
  4. extension="pcntl.so"

6.重新reload一下php

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

  1. [PHP Modules]
  2. bcmath
  3. ctype
  4. curl
  5. date
  6. dom
  7. filter
  8. gd
  9. hash
  10. iconv
  11. json
  12. libxml
  13. mbstring
  14. mcrypt
  15. memcache
  16. mhash
  17. mysql
  18. mysqli
  19. pcntl
  20. pcre
  21. PDO
  22. pdo_sqlite
  23. posix
  24. Reflection
  25. session
  26. shmop
  27. SimpleXML
  28. SPL
  29. SQLite
  30. standard
  31. sysvsem
  32. tokenizer
  33. XCache
  34. xml
  35. xmlreader
  36. xmlwriter
  37. zlib
  38.  
  39. [Zend Modules]
  40. 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.