在 CentOS 上配置 PHP cURL,你需要遵循以下步驟:
sudo yum install epel-release
sudo yum install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
sudo yum-config-manager --enable remi-php74
請注意,上述命令中的 php74
是 PHP 7.4 的版本。你可以根據需要更改為其他版本,例如 php80
。
sudo yum update
sudo yum install php-curl
sudo systemctl restart httpd
如果你使用的是 Nginx 和 PHP-FPM,請運行以下命令:
sudo systemctl restart nginx
sudo systemctl restart php-fpm
info.php
的文件,并在其中添加以下內容:<?php
phpinfo();
?>
將此文件上傳到你的 web 服務器,并通過瀏覽器訪問它(例如:http://your_server_ip/info.php
)。在顯示的 PHP 信息頁面中,你應該能看到與 cURL 相關的部分。完成驗證后,出于安全原因,建議刪除 info.php
文件。
現在你已經在 CentOS 上成功配置了 PHP cURL。