9_php擴充模組的安裝

來源:互聯網
上載者:User

標籤:php 添加動態模組

在此處樓主遇到一個問題,用命令查看,居然不出現php 的模組。

[[email protected] ~]# /usr/local/php/bin/php -m

於是進行到目錄下這樣操作,才出現,望解:

[[email protected] ~]# cd /usr/local/php/bin

[[email protected] bin]# ls

pear  peardev  pecl  phar  phar.phar  php  php-cgi  php-config  phpdbg  phpize

[[email protected] 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 的動態共用模組。

下面我們就來用第二種方法,編譯一個動態共用模組。

[[email protected] ~]# cd /usr/local/src/php-5.6.24  #進到php 的源碼包

[[email protected] 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


[[email protected] php-5.6.24]# cd ext/  # php 所有的塊都在這個目錄下

[[email protected] 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 為例進行編譯:

[[email protected] ext]# /usr/local/php/bin/php -m |grep -i curl

[[email protected] ext]# cd curl/

[[email protected] curl]# ls

config.m4  config.w32  CREDITS  curl.dsp  curl_file.c  interface.c  multi.c  package.xml  php_curl.h  share.c  tests

[[email protected] curl]# /usr/l

lib/     lib64/   libexec/ local/   

[[email protected] curl]# /usr/local/php/bin/phpize   #產生configure 檔案

Configuring for:

PHP Api Version:         20131106

Zend Module Api No:      20131226

Zend Extension Api No:   220131226

[[email protected] 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

[[email protected] 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.


[[email protected] curl]# cd /usr/local/src/


[[email protected] 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

然後就可以繼續了

排錯到此結束,繼續

———————————————————————————————————————————————

[[email protected] curl]# make install  #/curl.so 模組檔案會被放在下面這個目錄


Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/


[[email protected] 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 是存放擴充模組的。  也是可以自訂的。

[[email protected] curl]# cd /usr/local/php/bin/

[[email protected] 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 => no value


[[email protected] ~]# cd /usr/local/php/bin

[[email protected] bin]# php -m  # 此時是查看不到curl 這個模組的。剛才在php.ini檔案將模組名寫錯

來做測試 “curl1.so"

[[email protected] 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


[[email protected] 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擴充模組的安裝

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.