標籤:
按照如下教程:
LAMP一鍵安裝包-CentOS 5/6下自動編譯安裝Apache、MySQL、PHP
在虛擬機器的CentOS5.5中,一鍵安裝了PHP運行環境,但發現並沒有 soap 擴充,而近期項目用需要用到 webservice。
上述的一鍵安裝(lamp0.4),其實是源碼編譯安裝,PHP設定檔的路徑為 /etc/php.ini ,安裝後,遺留的檔案目錄為 “/home/jianbao/2/lamp0.4”,裡面的檔案清單為:
[[email protected] 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.gzdrwxrwxr-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.shdrwxr-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 命令:
[[email protected] soap]$ /usr/local/php/bin/phpizeConfiguring for:PHP Api Version: 20090626Zend Module Api No: 20090626Zend Extension Api No: 220090626
這時,會在目前的目錄產生 configure 等檔案。
4、運行 configure 命令:
[[email protected] soap]$ ./configure --with-php-config=/usr/local/php/bin/php-config --enable-soapchecking for egrep... grep -Echecking for a sed that does not truncate output... /bin/sedchecking for cc... ccchecking for C compiler default output file name... a.outchecking whether the C compiler works... yeschecking whether we are cross compiling... nochecking for suffix of executables...checking for suffix of object files... o.........checking if libtool supports shared libraries... yeschecking whether to build shared libraries... yeschecking whether to build static libraries... nocreating libtoolappending configuration tag "CXX" to libtoolconfigure: creating ./config.statusconfig.status: creating config.h
5、運行 make 命令:
[[email protected] 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 使用者即可。
[[email protected] soap]$ su口令:[[email protected] soap]# make installInstalling shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/[[email protected] 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[[email protected] 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:
[[email protected] jianbao]# /etc/init.d/httpd restart停止 httpd: [確定]啟動 httpd: [確定]
9、查看擴充是否已載入
[[email protected] jianbao]# /usr/local/php/bin/php -m[PHP Modules]CorectypecurldatedomeregfileinfofilterftpgdhashiconvjsonlibxmlmbstringmcryptmysqlopensslpcrePDOpdo_sqlitePharposixReflectionsessionSimpleXMLsoapSPLSQLitesqlite3standardtokenizerxmlxmlreaderxmlwriterzipzlib[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.soextension=sockets.soextension=pdo_mysql.soextension=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.x編譯安裝LAMP(1):準備工作
CentOS6.x編譯安裝LAMP(2):編譯安裝 Apache2.2.22
CentOS6.x編譯安裝LAMP(2):編譯安裝 Apache2.4.6
CentOS6.x編譯安裝LAMP(3):編譯安裝 MySQL5.5.25
CentOS6.x編譯安裝LAMP(4):編譯安裝 PHP5.2.17
CentOS6.x編譯安裝LAMP(4):編譯安裝 PHP5.3.27
PHP5不重新編譯,如何安裝內建的未安裝過的擴充,如soap擴充?
Linux下,如何給PHP安裝pdo_mysql擴充
CentOS6.x編譯安裝Memcached的PHP用戶端memcache
PHP5不重新編譯,如何安裝內建的未安裝過的擴充,如soap擴充?