繁体   English   中英

如何在 CentOS 8 中安装 php-curl?

[英]How do I install php-curl in CentOS 8?

如何在 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

它可从AppStream存储库中的php-common common 获得,默认情况下应启用。 确保已启用它,然后运行:

dnf install php-curl

笔记:
虽然dnf search php-curl不会显示任何内容,但dnf install php-curl将安装php-common

很晚了,但对于其他有同样问题的人,我发现这是由于升级 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 package 没有为此设置版本依赖项,因此它得到了升级,但我用dnf update libcurl修复了它。 重新启动 php/nginx,它已关闭并正在运行!

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

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

sudo yum install php-extension_name

现在您可以使用以下命令为 CentOs 安装一些常用的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

对我来说工作只需安装 curl

#dnf install curl

并重启 apache

# service httpd restart

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM