簡體   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