在 PHP 7.3 / Debian 9 Stretch 上安装 pecl_http 失败

在 PHP 7.3 / Debian 9 Stretch 上安装 pecl_http 失败

我尝试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

我不知道发生了什么事。有人知道为什么安装失败吗?

答案1

配置脚本确实告诉了您错误是什么:

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

您的系统没有适合编译软件的开发包。您需要先安装这些开发包。

sudo apt install libcurl-dev

答案2

Debian 系统的附加步骤:

我跟着迈克尔·汉普顿的答案。确实libcurl-dev缺少虚拟包。通过apt包管理系统安装后,pecl install pecl_http运行起来很顺利。

然而,debian 上的配置不是由佩克尔自动。我需要手动创建一个配置文件

/etc/php/7.3/mods-available内容如下:

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

然后我就可以启用在文件夹phpenmod http中创建符号链接的模块了conf.d

相关内容