php没有标准库,如何安装

问题描述 投票:0回答:1

我得到了一个带有 php 8 的 docker 镜像。我没有任何关于它是如何组装的细节,但我需要这个镜像。

所以,我运行它并选择它(带有 php 8.1.25 的 docker 镜像)。

我需要使用

sudo pecl install ***
(***任何软件包在这里都无关紧要)安装一个扩展,但我失败了:

running: make
/bin/bash /tmp/pear/temp/pear-build-rootNiAoW5/EXTENSION-1.0.0/libtool --mode=compile cc -I. -I/tmp/pear/temp/EXTENSION -I/tmp/pear/temp/pear-build-rootNiAoW5/EXTENSION-1.0.0/include -I/tmp/pear/temp/pear-build-rootNiAoW5/EXTENSION-1.0.0/main -I/tmp/pear/temp/EXTENSION -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib  -DHAVE_CONFIG_H  -g -O2    -DZEND_COMPILE_DL_EXT=1 -c /tmp/pear/temp/EXTENSION/EXTENSION.c -o EXTENSION.lo  -MMD -MF EXTENSION.dep -MT EXTENSION.lo
mkdir .libs
 cc -I. -I/tmp/pear/temp/EXTENSION -I/tmp/pear/temp/pear-build-rootNiAoW5/EXTENSION-1.0.0/include -I/tmp/pear/temp/pear-build-rootNiAoW5/EXTENSION-1.0.0/main -I/tmp/pear/temp/EXTENSION -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -DZEND_COMPILE_DL_EXT=1 -c /tmp/pear/temp/EXTENSION/EXTENSION.c -MMD -MF EXTENSION.dep -MT EXTENSION.lo  -fPIC -DPIC -o .libs/EXTENSION.o
/tmp/pear/temp/EXTENSION/EXTENSION.c:7:10: fatal error: ext/standard/info.h: No such file or directory
    7 | #include "ext/standard/info.h"
      |          ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:208: EXTENSION.lo] Error 1
ERROR: `make' failed

使用 docker-php install 命令

install-php-extensions ***
我还有另一个问题:

tar (child): /usr/src/php.tar.xz: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now

我发现这个 php 版本没有标准库,例如:

base64.h                   credits.h         dir_arginfo.h   fsock.h        md5.h           php_crypt.h       php_fopen_wrappers.h    php_math.h      php_smart_string.h         php_versioning.h  url.h
basic_functions_arginfo.h  credits_sapi.h    dl_arginfo.h    head.h         pack.h          php_crypt_r.h     php_http.h              php_mt_rand.h   php_smart_string_public.h  proc_open.h       url_scanner_ex.h
basic_functions.h          crypt_blowfish.h  dl.h            hrtime.h       pageinfo.h      php_dir.h         php_image.h             php_net.h       php_standard.h             quot_print.h      user_filters_arginfo.h
crc32.h                    crypt_freesec.h   exec.h          html.h         php_array.h     php_dns.h         php_incomplete_class.h  php_password.h  php_string.h               scanf.h           winver.h
crc32_x86.h                css.h             file.h          html_tables.h  php_assert.h    php_ext_syslog.h  php_lcg.h               php_rand.h      php_uuencode.h             sha1.h
credits_ext.h              datetime.h        flock_compat.h  info.h         php_browscap.h  php_filestat.h    php_mail.h              php_random.h    php_var.h                  streamsfuncs.h

我也尝试直接在源文件夹中并通过命令

sudo find / -name 'info.h'
找到它们,但系统没有显示任何迹象。

当我从其他 php 安装中复制并粘贴库到源文件夹中时

/usr/local/include/php/ext/standard/
它终于可以工作了。

现在我想知道如何在不复制或链接文件夹的情况下将库带到那里?可能有办法用其他工具安装它吗?如果有人知道如何做到这一点,请告诉我。

php docker pecl
1个回答
0
投票

您缺少的不是“标准库”,而是“代码头” - 运行程序不需要的源代码部分,但在编译扩展它的其他代码时使用。

确切的解决方案取决于您的 Docker 镜像所基于的系统 - Ubuntu、Alpine 等,您可能需要安装一个名为“php-dev”的软件包。

© www.soinside.com 2019 - 2024. All rights reserved.