Php

在 PHP 7.3 / Debian 9 Stretch 上安裝 pecl_http 失敗

  • September 21, 2019

我正在嘗試pecl_http在 PHP 7.3 中安裝,但是,出現錯誤:

root@dev:/etc/php/7.3/mods-available# pecl install pecl_http
downloading pecl_http-3.2.0.tgz ...
Starting to download pecl_http-3.2.0.tgz (218,829 bytes)
.............................................done: 218,829 bytes
84 source files, building
running: phpize
Configuring for:
PHP Api Version:         20180731
Zend Module Api No:      20180731
Zend Extension Api No:   320180731
where to find zlib [/usr] : 
where to find libcurl [/usr] : 
where to find libevent [/usr] : 
where to find libicu [/usr] : 
where to find libidn2 [/usr] : 
where to find libidn [/usr] : 
where to find libidnkit2 [/usr] : 
where to find libidnkit [/usr] : 
building in /tmp/pear/temp/pear-build-rooti6U7fE/pecl_http-3.2.0
running: /tmp/pear/temp/pecl_http/configure --with-php-config=/usr/bin/php-config --with-http-zlib-dir=/usr --with-http-libcurl-dir=/usr --with-http-libevent-dir=/usr --with-http-libicu-dir=/usr --with-http-libidn2-dir=/usr --with-http-libidn-dir=/usr --with-http-libidnkit2-dir=/usr --with-http-libidnkit-dir=/usr
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc

checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for PHP prefix... /usr
checking for PHP includes... -I/usr/include/php/20180731 -I/usr/include/php/20180731/main -I/usr/include/php/20180731/TSRM -I/usr/include/php/20180731/Zend -I/usr/include/php/20180731/ext -I/usr/include/php/20180731/ext/date/lib
checking for PHP extension directory... /usr/lib/php/20180731
checking for PHP installed headers prefix... /usr/include/php/20180731
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
checking for gawk... gawk
checking whether to enable extended HTTP support... yes, shared
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for off_t... yes
checking for mbstate_t... yes
checking netdb.h usability... yes
checking netdb.h presence... yes
checking for netdb.h... yes
checking for unistd.h... (cached) yes
checking wchar.h usability... yes
checking wchar.h presence... yes
checking for wchar.h... yes
checking wctype.h usability... yes
checking wctype.h presence... yes
checking for wctype.h... yes
checking arpa/inet.h usability... yes
checking arpa/inet.h presence... yes
checking for arpa/inet.h... yes
checking for gethostname... yes
checking for getdomainname... yes
checking for mbrtowc... yes
checking for mbtowc... yes
checking for iswalnum... yes
checking for inet_pton... yes
checking whether/where to check for zlib... /usr
checking for gawk... (cached) gawk
checking for zlib... 1.2.8
checking whether zlib version 1.2.8 >= 1.2.0.4... ok
checking whether/where to check for libbrotli... yes
checking for pkg-config... /usr/bin/pkg-config
checking for libbrotlicommon... no
checking whether libbrotlicommon version  >= 1.0... no
checking for libbrotlidec... no
checking whether libbrotlidec version  >= 1.0... no
checking for libbrotlienc... no
checking whether libbrotlienc version  >= 1.0... no
checking whether/where to check for libcurl... /usr
checking for a sed that does not truncate output... (cached) /bin/sed
checking for egrep... (cached) /bin/grep -E
checking for curl-config... false
checking for libcurl... no
checking whether libcurl version  >= 7.18.2... configure: error: no
ERROR: `/tmp/pear/temp/pecl_http/configure --with-php-config=/usr/bin/php-config --with-http-zlib-dir=/usr --with-http-libcurl-dir=/usr --with-http-libevent-dir=/usr --with-http-libicu-dir=/usr --with-http-libidn2-dir=/usr --with-http-libidn-dir=/usr --with-http-libidnkit2-dir=/usr --with-http-libidnkit-dir=/usr' failed

首先,為什麼要問我幾個圖書館的位置?然後在 上發生錯誤configure

/etc/apt/sources.list.d/php-sury.org.list包含:

deb https://packages.sury.org/php/ stretch main

可用的 PHP 模組:

root@dev:/etc/php/7.3/mods-available# l
insgesamt 192K
drwxr-xr-x 2 root root 4,0K Jan  5 03:50 ./
drwxr-xr-x 5 root root 4,0K Jul 22  2018 ../
-rw-r--r-- 1 root root   74 Jul 17  2018 calendar.ini
-rw-r--r-- 1 root root   71 Jul 17  2018 ctype.ini
-rw-r--r-- 1 root root   68 Jul 17  2018 curl.ini
-rw-r--r-- 1 root root   66 Jul 17  2018 dom.ini
-rw-r--r-- 1 root root   70 Jul 17  2018 exif.ini
-rw-r--r-- 1 root root   74 Jul 17  2018 fileinfo.ini
-rw-r--r-- 1 root root   69 Jul 17  2018 ftp.ini
-rw-r--r-- 1 root root   64 Jul 17  2018 gd.ini
-rw-r--r-- 1 root root   73 Jul 17  2018 gettext.ini
-rw-r--r-- 1 root root   71 Jul 17  2018 iconv.ini
-rw-r--r-- 1 root root   68 Dez 17 10:26 imap.ini
-rw-r--r-- 1 root root   68 Jul 17  2018 intl.ini
-rw-r--r-- 1 root root   68 Jul 17  2018 json.ini
-rw-r--r-- 1 root root   71 Jul 17  2018 mysqli.ini
-rw-r--r-- 1 root root   72 Jul 17  2018 mysqlnd.ini
-rw-r--r-- 1 root root   68 Jul 17  2018 odbc.ini
-rw-r--r-- 1 root root   79 Jul 17  2018 opcache.ini
-rw-r--r-- 1 root root   69 Jul 17  2018 pdo.ini
-rw-r--r-- 1 root root   74 Jul 17  2018 pdo_mysql.ini
-rw-r--r-- 1 root root   72 Jul 17  2018 pdo_odbc.ini
-rw-r--r-- 1 root root   74 Jul 17  2018 pdo_pgsql.ini
-rw-r--r-- 1 root root   77 Jul 17  2018 pdo_sqlite.ini
-rw-r--r-- 1 root root   70 Jul 17  2018 pgsql.ini
-rw-r--r-- 1 root root   70 Jul 17  2018 phar.ini
-rw-r--r-- 1 root root   71 Jul 17  2018 posix.ini
-rw-r--r-- 1 root root   20 Aug 19 17:08 propro.ini
-rw-r--r-- 1 root root   19 Aug 19 17:08 raphf.ini
-rw-r--r-- 1 root root   76 Jul 17  2018 readline.ini
-rw-r--r-- 1 root root   71 Jul 17  2018 shmop.ini
-rw-r--r-- 1 root root   72 Jul 17  2018 simplexml.ini
-rw-r--r-- 1 root root   68 Jul 17  2018 soap.ini
-rw-r--r-- 1 root root   73 Jul 17  2018 sockets.ini
-rw-r--r-- 1 root root   74 Jul 17  2018 sqlite3.ini
-rw-r--r-- 1 root root   73 Jul 17  2018 sysvmsg.ini
-rw-r--r-- 1 root root   73 Jul 17  2018 sysvsem.ini
-rw-r--r-- 1 root root   73 Jul 17  2018 sysvshm.ini
-rw-r--r-- 1 root root   68 Jul 17  2018 tidy.ini
-rw-r--r-- 1 root root   75 Jul 17  2018 tokenizer.ini
-rw-r--r-- 1 root root   67 Jul 17  2018 wddx.ini
-rw-r--r-- 1 root root   25 Okt 19 09:02 xdebug.ini
-rw-r--r-- 1 root root   66 Jul 17  2018 xml.ini
-rw-r--r-- 1 root root   72 Jul 17  2018 xmlreader.ini
-rw-r--r-- 1 root root   72 Jul 17  2018 xmlrpc.ini
-rw-r--r-- 1 root root   72 Jul 17  2018 xmlwriter.ini
-rw-r--r-- 1 root root   66 Jul 17  2018 xsl.ini
-rw-r--r-- 1 root root   66 Jul 17  2018 zip.ini

載入的 PHP 模組:

root@dev:/etc/php/7.3/mods-available# php -m
[PHP Modules]
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
imap
intl
json
libxml
mysqli
mysqlnd
odbc
openssl
pcntl
pcre
PDO
pdo_mysql
PDO_ODBC
pdo_pgsql
pdo_sqlite
pgsql
Phar
posix
propro
raphf
readline
Reflection
session
shmop
SimpleXML
soap
sockets
sodium
SPL
sqlite3
standard
sysvmsg
sysvsem
sysvshm
tidy
tokenizer
wddx
xdebug
xml
xmlreader
xmlrpc
xmlwriter
xsl
Zend OPcache
zip
zlib

[Zend Modules]
Xdebug
Zend OPcache

替代品預設設置為 PHP7.3

root@dev:/etc/php/7.3/mods-available# l /etc/alternatives/php*
lrwxrwxrwx 1 root root 15 Jul 22  2018 /etc/alternatives/php -> /usr/bin/php7.3*
lrwxrwxrwx 1 root root 31 Jul 22  2018 /etc/alternatives/php.1.gz -> /usr/share/man/man1/php7.3.1.gz
lrwxrwxrwx 1 root root 22 Nov 27 03:08 /etc/alternatives/php-config -> /usr/bin/php-config7.3*
lrwxrwxrwx 1 root root 38 Nov 27 03:08 /etc/alternatives/php-config.1.gz -> /usr/share/man/man1/php-config7.3.1.gz
lrwxrwxrwx 1 root root 18 Nov 27 03:08 /etc/alternatives/phpize -> /usr/bin/phpize7.3*
lrwxrwxrwx 1 root root 34 Nov 27 03:08 /etc/alternatives/phpize.1.gz -> /usr/share/man/man1/phpize7.3.1.gz

我不知道這裡發生了什麼。有人知道為什麼安裝失敗嗎?

配置腳本確實告訴您錯誤是什麼:

checking whether libcurl version  >= 7.18.2... configure: error: no

您的系統沒有用於編譯軟體的適當開發包。您需要先安裝這些開發包。

sudo apt install libcurl-dev

Debian 系統的附加步驟:

我跟著邁克爾漢普頓的回答。libcurl-dev確實缺少虛擬包。通過apt包管理系統安裝後,pecl install pecl_http工作就像一個魅力。

但是,debian 上的配置不是由pecl自動完成的。我需要手動創建一個配置文件

/etc/php/7.3/mods-available包含以下內容:

; configuration for php http module
; priority=20
extension=http.so

然後我能夠啟用在文件夾phpenmod http中創建符號連結的模組。conf.d

引用自:https://serverfault.com/questions/951375