PHP5不重新編譯,如何安裝自帶的未安裝過的擴展,如soap擴展?


在虛擬機的CentOS5.5中,一鍵安裝了PHP運行環境,但發現並沒有 soap 擴展,而近期項目用需要用到 webservice。

上述的一鍵安裝(lamp0.4),其實是源碼編譯安裝,PHP配置文件的路徑為 /etc/php.ini ,安裝后,遺留的文件目錄為 “/home/jianbao/2/lamp0.4”,里面的文件列表為:

[root@localhost lamp0.4]# ll
總計 59296
-rw-r--r-- 1 root    root      982243 2012-05-23 apr-1.4.6.tar.gz
-rw-r--r-- 1 root    root      774770 2012-05-23 apr-util-1.4.1.tar.gz
drwxrwxr-x 2 jianbao jianbao     4096 2012-05-29 conf
-rw-r--r-- 1 root    root     5616185 2012-05-23 httpd-2.4.2.tar.gz
-rwxrwxr-x 1 jianbao jianbao    25116 2012-06-28 lamp.sh
-rw-r--r-- 1 root    root     4984397 2012-01-21 libiconv-1.14.tar.gz
-rw-r--r-- 1 root    root     1335178 2012-03-26 libmcrypt-2.5.8.tar.gz
-rw-r--r-- 1 root    root      471915 2012-03-26 mcrypt-2.6.8.tar.gz
-rw-r--r-- 1 root    root      931437 2012-03-26 mhash-0.9.9.9.tar.gz
-rw-r--r-- 1 root    root    24518874 2012-05-10 mysql-5.5.24.tar.gz
-rw-r--r-- 1 root    root    14913792 2012-05-10 php-5.3.13.tar.gz
-rw-r--r-- 1 root    root     5944741 2012-05-10 phpMyAdmin-3.5.1-all-languages.tar.gz
-rwxrwxr-x 1 jianbao jianbao     1792 2012-05-29 pureftpd.sh
drwxr-xr-x 2 root    root        4096 06-09 21:36 untar
-rwxrwxr-x 1 jianbao jianbao     1563 2012-02-14 xcache.sh
-rwxrwxr-x 1 jianbao jianbao     2720 2012-06-15 zend.sh

我選擇的PHP版本為上述的 php-5.3.13.tar.gz,現在需要做的事情是:

1、把 “php-5.3.13.tar.gz”源碼壓縮包拷貝的另外一個目錄,如 “/home/jianbao/1”,並解壓

2、切換到解壓后的 soap 源碼目錄:

cd  /home/jianbao/1/php-5.3.13/ext/soap

3、運行 phpize 命令:

[jianbao@localhost soap]$ /usr/local/php/bin/phpize
Configuring for:
PHP Api Version:         20090626
Zend Module Api No:      20090626
Zend Extension Api No:   220090626

這時,會在當前目錄生成 configure 等文件。

4、運行 configure 命令:

[jianbao@localhost soap]$ ./configure --with-php-config=/usr/local/php/bin/php-config --enable-soap
checking for egrep... grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
...
...
...
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no

creating libtool
appending configuration tag "CXX" to libtool
configure: creating ./config.status
config.status: creating config.h

5、運行 make 命令:

[jianbao@localhost soap]$ make
/bin/sh /home/jianbao/1/php-5.3.13/ext/soap/libtool --mode=compile cc  -I. -I/home/jianbao/1/php-5.3.13/ext/soap -DPHP_ATOM_INC ......

6、運行 make  install 命令:

注意,會出現權限問題,臨時切換到 root 用戶即可。

[jianbao@localhost soap]$ su
口令:
[root@localhost soap]# make install
Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/
[root@localhost soap]# ll /usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/
總計 832
-rwxr-xr-x 1 root root 840501 06-10 01:09 soap.so
[root@localhost soap]#

安裝好之后會提示 soap.so 文件的保存路徑

7、修改 /etc/php.ini 文件:

找到 extension_dir="./",默認是注釋掉的,

修改為 extension_dir="/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/" 

並在此行后增加如下配置:

extension=soap.so

然后保存。

8、重啟 Apache:

[root@localhost jianbao]# /etc/init.d/httpd restart
停止 httpd:                                               [確定]
啟動 httpd:                                               [確定]

9、查看擴展是否已加載

[root@localhost jianbao]# /usr/local/php/bin/php -m
[PHP Modules]
Core
ctype
curl
date
dom
ereg
fileinfo
filter
ftp
gd
hash
iconv
json
libxml
mbstring
mcrypt
mysql
openssl
pcre
PDO
pdo_sqlite
Phar
posix
Reflection
session
SimpleXML
soap
SPL
SQLite
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
zip
zlib

[Zend Modules]

soap 已在里面啦,安裝成功!!!

今后,要安裝其他的擴展,同理可得。

 


 

/usr/local/php/bin/phpize

#安裝 soap擴展  configure 命令: 

./configure --with-php-config=/usr/local/php/bin/php-config --enable-soap

#安裝 socket擴展 configure 命令: 

./configure --with-php-config=/usr/local/php/bin/php-config --enable-sockets

#安裝 pdo_mysql擴展  configure 命令: 

./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysql

#安裝 mysqli擴展  configure 命令: 

./configure --with-php-config=/usr/local/php/bin/php-config -with-mysqli=/usr/local/mysql/bin/mysql_config

#另外,別忘了給 php.ini 添加的相應的擴展配置:

extension=soap.so
extension=sockets.so
extension=pdo_mysql.so
extension=mysqli.so

 


 

Windows服務器下PHP擴展的啟用比較簡單,官方擴展說明:http://www.php.net/manual/zh/install.windows.extensions.php

Linux擴展:http://pecl.php.net/package/PDO_MYSQL (pdo_mysql)

 

 

延伸閱讀:

CentOS6.3編譯安裝LAMP(1):准備工作

CentOS6.3編譯安裝LAMP(2):編譯安裝 Apache2.2.25

CentOS6.3編譯安裝LAMP(2):編譯安裝 Apache2.4.6

CentOS6.3編譯安裝LAMP(3):編譯安裝 MySQL5.5.25

CentOS6.3編譯安裝LAMP(4):編譯安裝 PHP5.2.17

CentOS6.3編譯安裝LAMP(4):編譯安裝 PHP5.3.27

PHP5不重新編譯,如何安裝自帶的未安裝過的擴展,如soap擴展?  

Linux下,如何給PHP安裝pdo_mysql擴展

CentOS6.x編譯安裝Memcached的PHP客戶端memcache

 

CentOS 7.x,不重新編譯 PHP,動態安裝 imap 擴展


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM