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

k3bvogb1  于 2022-11-13  发布在  PHP
关注(0)|答案(3)|浏览(277)

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

ev7lccsx1#

很晚了,但是对于其他有同样问题的人,我发现这是由于升级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,它关闭并运行!
(note:如果您不使用dnf,则应该可以使用yum(即yum update libcurl

5ktev3wc

5ktev3wc2#

使用以下语法安装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
sirbozc5

sirbozc53#

对于我的工作只是安装curl

#dnf install curl

并重新启动Apache

# service httpd restart

相关问题