首页 > 代码库 > 9_php扩展模块的安装
9_php扩展模块的安装
在此处楼主遇到一个问题,用命令查看,居然不出现php 的模块。
[root@OBird ~]# /usr/local/php/bin/php -m
于是进行到目录下这样操作,才出现,望解:
[root@OBird ~]# cd /usr/local/php/bin
[root@OBird bin]# ls
pear peardev pecl phar phar.phar php php-cgi php-config phpdbg phpize
[root@OBird bin]# php -m
[PHP Modules] # 此时静态或动态文件是看不出来的。动态的是可以在 php.ini 里面去定义。
Core
ctype
date
dom
ereg
fileinfo
filter
hash
iconv
json
libxml
mysqli
pcre
PDO
pdo_sqlite
Phar
posix
Reflection
session
SimpleXML
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
[Zend Modules]
有时候我们会发现有些模块没有编译进来,有两种办法,一是找到源码包重编译。二使用动态的方式来加载。类似于apache 的动态共享模块。
下面我们就来用第二种方法,编译一个动态的共享模块。
[root@OBird ~]# cd /usr/local/src/php-5.6.24 #进到php 的源码包
[root@OBird php-5.6.24]# ls
acinclude.m4 generated_lists Makefile.global README.MAILINGLIST_RULES server-tests-config.php
aclocal.m4 genfiles Makefile.objects README.md server-tests.php
build header makerpm README.namespaces snapshot
buildconf include missing README.NEW-OUTPUT-API stamp-h.in
buildconf.bat INSTALL mkinstalldirs README.PARAMETER_PARSING_API stub.c
CODING_STANDARDS install-sh modules README.REDIST.BINS tests
config.guess libphp5.la netware README.RELEASE_PROCESS travis
config.log libs NEWS README.SELF-CONTAINED-EXTENSIONS TSRM
config.nice libtool pear README.STREAMS UPGRADING
config.status LICENSE php5.spec README.SUBMITTING_PATCH UPGRADING.INTERNALS
config.sub ltmain.sh php5.spec.in README.TESTING vcsclean
configure main php.gif README.TESTING2 win32
configure.in makedist php.ini-development README.UNIX-BUILD-SYSTEM Zend
CREDITS Makefile php.ini-production README.WIN32-BUILD-SYSTEM
ext Makefile.frag README.EXT_SKEL run-tests.php
EXTENSIONS Makefile.fragments README.GIT-RULES sapi
footer Makefile.gcov README.input_filter scripts
[root@OBird php-5.6.24]# cd ext/ # php 所有的块都在这个目录下
[root@OBird ext]# ls
bcmath dom ftp intl mysqli pdo pgsql shmop standard xml
bz2 enchant gd json mysqlnd pdo_dblib phar simplexml sybase_ct xmlreader
calendar ereg gettext ldap oci8 pdo_firebird posix skeleton sysvmsg xmlrpc
com_dotnet exif gmp libxml odbc pdo_mysql pspell snmp sysvsem xmlwriter
ctype ext_skel hash mbstring opcache pdo_oci readline soap sysvshm xsl
curl ext_skel_win32.php iconv mcrypt openssl pdo_odbc recode sockets tidy zip
date fileinfo imap mssql pcntl pdo_pgsql reflection spl tokenizer zlib
dba filter interbase mysql pcre pdo_sqlite session sqlite3 wddx
以 curl 为例进行编译:
[root@OBird ext]# /usr/local/php/bin/php -m |grep -i curl
[root@OBird ext]# cd curl/
[root@OBird curl]# ls
config.m4 config.w32 CREDITS curl.dsp curl_file.c interface.c multi.c package.xml php_curl.h share.c tests
[root@OBird curl]# /usr/l
lib/ lib64/ libexec/ local/
[root@OBird curl]# /usr/local/php/bin/phpize #生成configure 文件
Configuring for:
PHP Api Version: 20131106
Zend Module Api No: 20131226
Zend Extension Api No: 220131226
[root@OBird curl]# ls
acinclude.m4 build config.m4 configure.in curl.dsp interface.c missing package.xml share.c
aclocal.m4 config.guess config.sub config.w32 curl_file.c ltmain.sh mkinstalldirs php_curl.h tests
autom4te.cache config.h.in configure CREDITS install-sh Makefile.global multi.c run-tests.php
[root@OBird curl]# ./configure --with-php-config=/usr/local/php/bin/php-config
———————————————————————————————————————————————
楼主在编译的过程中出现了报错,那么就停下解决问题
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
[root@OBird curl]# cd /usr/local/src/
[root@OBird src]# wget https://github.com/skvadrik/re2c/releases/download/0.13.6/re2c-0.13.6.tar.gz
# tar xf re2c 0.13.4.tar.gz
# cd re2c 0.13.4
# ./configure
#make && make install
后面还是出错
checking for cURL in default path... not found
configure: error: Please reinstall the libcurl distribution -
easy.h should be in <curl-dir>/include/curl/
在网上找到了解决办法
php安装错误configure: error: Please reinstall the libcurl distribu
今天配置一台server的php支持curl的时候, 出现如下报错
checking for cURL in default path... not found
configure: error: Please reinstall the libcurl distribution -
easy.h should be in /include/curl/
其实就是curl的dev包没有安装,
解决方案:
终端下
# yum -y install curl-devel
然后就可以继续了
排错到此结束,继续
———————————————————————————————————————————————
[root@OBird curl]# make install #/curl.so 模块文件会被放在下面这个目录
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/
[root@OBird curl]# ls /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/curl.so
/usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/curl.so
extension_dir 是存放扩展模块的。 也是可以自定义的。
[root@OBird curl]# cd /usr/local/php/bin/
[root@OBird bin]# php -i |grep extension_dir
extension_dir => /usr/local/lib/php/extensions/no-debug-non-zts-20131226 => /usr/local/lib/php/extensions/no-debug-non-zts-20131226
sqlite3.extension_dir => no value =http://www.mamicode.com/> no value
[root@OBird ~]# cd /usr/local/php/bin
[root@OBird bin]# php -m # 此时是查看不到curl 这个模块的。刚才在php.ini文件将模块名写错
来做测试 “curl1.so"
[root@OBird bin]# tail /usr/local/php/logs/php_errors.log
[02-Oct-2016 09:00:31 UTC] PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/curl1.so‘ - /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/curl1.so: cannot open shared object file: No such file or directory in Unknown on line 0
[root@OBird bin]# vim /usr/local/php/etc/php.ini
extension=curl1.so # 修正
正常再重新加载就可以看到 curl这个模块,但是楼主不知是哪里出错了,这个效果没有做出来,但是curl 这个命令可以正常使用。只能先跳过去 了。
本文出自 “CBO#Boy_Linux之路” 博客,请务必保留此出处http://20151213start.blog.51cto.com/9472657/1858499
9_php扩展模块的安装