標籤:lamp php 安裝 擴充模組
查看PHP模組
[[email protected] ~]# php -m
[PHP Modules]
bz2
Core
ctype
date
dom
ereg
exif
fileinfo
filter
gd
hash
iconv
json
libxml
mbstring
mcrypt
mysql
openssl
pcre
PDO
pdo_sqlite
Phar
posix
Reflection
session
SimpleXML
soap
sockets
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
zlib
[Zend Modules]
如果我們發現有一個模組沒有編譯進來,解決辦法有兩種:第一,需要重新編譯,重新設定;第二,單獨編譯該模組,使用動態共用的方式載入該模組。我們自己嘗試編譯一個PHP動態共用模組。
PHP安裝包的ext目錄下包含了許多模組的原始碼:
[[email protected] ~]# cd /usr/local/src/php-5.4.36
[[email protected] php-5.4.36]# cd ext
[[email protected] ext]# ls
bcmath dba fileinfo iconv mbstring odbc pdo_mysql posix simplexml standard wddx zlib
bz2 dom filter imap mcrypt openssl pdo_oci pspell skeleton sybase_ct xml
calendar enchant ftp interbase mssql pcntl pdo_odbc readline snmp sysvmsg xmlreader
com_dotnet ereg gd intl mysql pcre pdo_pgsql recode soap sysvsem xmlrpc
ctype exif gettext json mysqli pdo pdo_sqlite reflection sockets sysvshm xmlwriter
curl ext_skel gmp ldap mysqlnd pdo_dblib pgsql session spl tidy xsl
date ext_skel_win32.php hash libxml oci8 pdo_firebird phar shmop sqlite3 tokenizer zip
PHP預設沒有沒有安裝curl模組,下面命令返回無結果:
[[email protected] ext]# php -m |grep -i curl
我們以編譯安裝PHP的curl模組為例進行說明:進入curl目錄
[[email protected] ext]# cd curl
[[email protected] curl]# ls
config.m4 config.w32 CREDITS curl.dsp interface.c multi.c package.xml php_curl.h streams.c tests
產生configure相關的檔案:
[[email protected] curl]# yum install -y m4 autoconf#安裝兩個自動產生configure的工具
[[email protected] curl]# /usr/local/php/bin/phpize#產生configure
Configuring for:
PHP Api Version: 20100412
Zend Module Api No: 20100525
Zend Extension Api No: 220100525
[[email protected] curl]# ls
acinclude.m4 config.h.in config.w32 ltmain.sh package.xml
aclocal.m4 config.m4 CREDITS Makefile.global php_curl.h
autom4te.cache config.sub curl.dsp missing run-tests.php
build configure install-sh mkinstalldirs streams.c
config.guess configure.in interface.c multi.c tests
配置
[[email protected] curl]# ./configure --with-php-config=/usr/local/php/bin/php-config
錯誤1:configure: error: Please reinstall the libcurl distribution -
easy.h should be in <curl-dir>/include/curl/
解決:[[email protected] curl]# yum -y install curl-devel
編譯
[[email protected] curl]# make
[[email protected] curl]# echo $?
0
安裝
[[email protected] curl]# make install
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/
[[email protected] curl]# echo $?
0
模組已產生
[[email protected] curl]# ls /usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/
curl.so
查看extension_dir
[[email protected] curl]# php -i |grep extension_dir
extension_dir => /usr/local/php/lib/php/extensions/no-debug-non-zts-20100525 => /usr/local/php/lib/php/extensions/no-debug-non-zts-20100525
sqlite3.extension_dir => no value => no value
[[email protected] curl]# ls /usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/
curl.so
也可以自訂extension_dir
[[email protected] curl]# vim /usr/local/php/etc/php.ini
……
; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
; extension_dir = "./"
; On windows:
; extension_dir = "ext"
……
配置載入curl.so
……
;extension=php_pgsql.dll
;extension=php_pspell.dll
;extension=php_shmop.dll
extension=curl.so
……
查看動態載入的模組
[[email protected] curl]# php -m |grep curl
curl
LAMP搭建18:PHP安裝擴充模組