【问题标题】:How do I install php-curl in CentOS 8?如何在 CentOS 8 中安装 php-curl?
【发布时间】:2020-11-07 23:24:42
【问题描述】:

如何在 CentOS 8 上快速安装php-curl?它似乎在基础软件存储库中不可用,甚至在 EPEL 中也不可用。

更新:

[root@example ~]# dnf repolist            
repo id                                 repo name
AppStream                               CentOS-8 - AppStream
BaseOS                                  CentOS-8 - Base
epel                                    Extra Packages for Enterprise Linux 8 - x86_64
epel-modular                            Extra Packages for Enterprise Linux Modular 8 - x86_64
extras                                  CentOS-8 - Extras

[root@example ~]# dnf search php-curl
Last metadata expiration check: 0:08:15 ago on Sat 18 Jul 2020 08:48:47 AM UTC.
No matches found.

[root@example ~]# dnf search php-*
Last metadata expiration check: 0:08:26 ago on Sat 18 Jul 2020 08:48:47 AM UTC.
================================================== Name Matched: php-* ==================================================
php-gd.x86_64 : A module for PHP applications for using the gd graphics library
php-cli.x86_64 : Command-line interface for PHP
php-fpm.x86_64 : PHP FastCGI Process Manager
php-pdo.x86_64 : A database access abstraction module for PHP applications
php-xml.x86_64 : A module for PHP applications which use XML
php-dba.x86_64 : A database abstraction layer module for PHP applications
php-dbg.x86_64 : The interactive PHP debugger
php-gmp.x86_64 : A module for PHP applications for using the GNU MP library
php-json.x86_64 : JavaScript Object Notation extension for PHP
php-intl.x86_64 : Internationalization extension for PHP applications
php-ldap.x86_64 : A module for PHP applications that use LDAP
php-odbc.x86_64 : A module for PHP applications that use ODBC databases
php-pear.noarch : PHP Extension and Application Repository framework
php-snmp.x86_64 : A module for PHP applications that query SNMP-managed devices
php-soap.x86_64 : A module for PHP applications that use the SOAP protocol
php-devel.x86_64 : Files needed for building PHP extensions
php-pgsql.x86_64 : A PostgreSQL database module for PHP
php-common.x86_64 : Common files for PHP
php-bcmath.x86_64 : A module for PHP applications for using the bcmath library
php-recode.x86_64 : A module for PHP applications for using the recode library
php-xmlrpc.x86_64 : A module for PHP applications which use the XML-RPC protocol
php-mysqlnd.x86_64 : A module for PHP applications that use MySQL databases
php-opcache.x86_64 : The Zend OPcache
php-enchant.x86_64 : Enchant spelling extension for PHP applications
php-process.x86_64 : Modules for PHP script using system process interfaces
php-mbstring.x86_64 : A module for PHP applications which need multi-byte string handling
php-pecl-zip.x86_64 : A ZIP archive management extension
php-embedded.x86_64 : PHP library for embedding in applications
php-pecl-apcu.x86_64 : APC User Cache
php-pear-Date.noarch : Date and Time Zone Classes
php-pear-Mail.noarch : Class that provides multiple interfaces for sending emails
php-pear-Net-URL.noarch : Easy parsing of URLs
php-pear-Net-SMTP.noarch : Provides an implementation of the SMTP protocol
php-pear-Auth-SASL.noarch : Abstraction of various SASL mechanism responses
php-pecl-apcu-devel.x86_64 : APCu developer files (header)
php-pear-Cache-Lite.noarch : Fast and Safe little cache system for PHP
php-pear-Net-Socket.noarch : Network Socket Interface
php-pear-HTTP-Request.noarch : Provides an easy way to perform HTTP requests

[root@example ~]# dnf search curl
Last metadata expiration check: 0:10:34 ago on Sat 18 Jul 2020 08:48:47 AM UTC.
============================================== Name Exactly Matched: curl ===============================================
curl.x86_64 : A utility for getting files from remote servers (FTP, HTTP, and others)
============================================= Name & Summary Matched: curl ==============================================
collectd-curl.x86_64 : Curl plugin for collectd
qemu-kvm-block-curl.x86_64 : QEMU CURL block driver
collectd-curl_xml.x86_64 : Curl XML plugin for collectd
collectd-curl_json.x86_64 : Curl JSON plugin for collectd
perl-WWW-Curl.x86_64 : Perl extension interface for libcurl
python3-pycurl.x86_64 : Python interface to libcurl for Python 3
libcurl-devel.i686 : Files needed for building applications with libcurl
libcurl-devel.x86_64 : Files needed for building applications with libcurl
libcurl-minimal.i686 : Conservatively configured build of libcurl for minimal installations
libcurl-minimal.x86_64 : Conservatively configured build of libcurl for minimal installations
================================================== Name Matched: curl ===================================================
libcurl.x86_64 : A library for getting files from web servers
libcurl.i686 : A library for getting files from web servers
================================================= Summary Matched: curl =================================================
rubygem-curb.x86_64 : Ruby libcurl bindings

【问题讨论】:

  • 您能否展示您尝试安装它的内容和消息(如果可能,请添加为文本而不是图像)。
  • @NigelRen 抱歉,现在更新了。
  • 你找到解决办法了吗?

标签: php curl centos8


【解决方案1】:

很晚了,但是对于其他有同样问题的人,我发现这是由于升级了 PHP(在我的例子中是从 5.6 到 7.2);并非所有依赖项都已正确更新。

尝试通过在 shell 中打开 PHP 进行诊断(只需输入 php)。如果你看到这样的警告(注意最后的undefined symbol: curl_pushheader_bynum):

PHP Warning:  PHP Startup: Unable to load dynamic library 'curl' (tried: /usr/lib64/php/modules/curl (/usr/lib64/php/modules/curl: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/curl.so (/usr/lib64/php/modules/curl.so: undefined symbol: curl_pushheader_bynum)) in Unknown on line 0

您可能有一个过时版本的 curl 库。不知道为什么php-common 包没有为此设置版本依赖项,因此它得到了升级,但我用dnf update libcurl 修复了它。重新启动 php/nginx,它关闭并运行!

(注意:如果您不使用dnf,您应该可以使用yum 代替,即yum update libcurl

【讨论】:

    【解决方案2】:

    使用以下语法安装 PHP 扩展很简单。

    sudo yum install php-extension_name
    

    现在你可以使用以下命令安装一些常用的 CentO 的php-extensions

    sudo yum install -y php-dom php-simplexml php-ssh2 php-xml php-xmlreader php-curl php-date php-exif php-filter php-ftp php-gd php-hash php-iconv php-json php-libxml php-pecl-imagick php-mbstring php-mysqlnd php-openssl php-pcre php-posix php-sockets php-spl php-tokenizer php-zlib
    

    【讨论】:

    • 对不起,还是不行,我更新了问题,请问是什么问题?谢谢!
    • yum 不适用于 CentOS 8,已被 dnf 取代;此外,php-curl 现在是 php-common 的别名,它已安装。
    【解决方案3】:

    对我来说工作只需安装 curl

    #dnf install curl
    

    然后重启apache

    # service httpd restart
    

    【讨论】:

    • curlphp-commonphp-curl 别名)已经安装,我仍然收到此错误,显然 OP 也是如此(自 2020 年 7 月 18 日起)
    猜你喜欢
    • 2020-12-11
    • 1970-01-01
    • 1970-01-01
    • 2023-03-20
    • 2021-06-23
    • 1970-01-01
    • 2020-06-29
    • 2014-09-27
    • 2019-08-16
    相关资源
    最近更新 更多