ARTICLE DETAIL

资讯详情

深耕网站视觉设计与运营推广的一线实战洞察。

centOS stream 9 升级cURL到8.17版本

centOS stream 9 升级cURL到8.17版本 环境centOS stream 9\php8.3.27系统自带的cURL的版本7.66版本太低了在请求微信公众号或小程序时使用easywechat插件请求时报错通过多方查找原因得知cURL版本过低造成的通过AI创建了一个自动执行的脚本来升级cURL;#!/usr/bin/env bash set -e CURL_VERSION8.17.0 CURL_FILEcurl-${CURL_VERSION}.tar.xz CURL_URLhttps://curl.se/download/${CURL_FILE} SRC_DIR/usr/local/src/curl-${CURL_VERSION} echo echo Installing curl ${CURL_VERSION} for CentOS Stream 9 echo Supports: OpenSSL HTTP/2 (WeChat APIs) echo # ------------------------------------------------------ # 1. Install dependencies # ------------------------------------------------------ echo ➡️ Installing build dependencies... sudo dnf groupinstall -y Development Tools sudo dnf install -y openssl-devel libtool autoconf automake pkgconfig zlib-devel \ libpsl-devel libzstd-devel brotli-devel libnghttp2-devel # ------------------------------------------------------ # 2. Prepare source directory # ------------------------------------------------------ echo ➡️ Downloading curl ${CURL_VERSION}... sudo rm -rf ${SRC_DIR} sudo mkdir -p ${SRC_DIR} cd ${SRC_DIR} sudo curl -LO ${CURL_URL} echo ➡️ Extracting... sudo tar -xf ${CURL_FILE} --strip-components1 # ------------------------------------------------------ # 3. Configure with OpenSSL HTTP2 # ------------------------------------------------------ echo ➡️ Configuring curl (OpenSSL HTTP/2)... sudo ./configure --with-openssl --with-nghttp2 # ------------------------------------------------------ # 4. Build # ------------------------------------------------------ echo ➡️ Building curl... sudo make -j$(nproc) # ------------------------------------------------------ # 5. Install curl # ------------------------------------------------------ echo ➡️ Installing curl... sudo make install sudo ldconfig # ------------------------------------------------------ # 6. Validate curl version # ------------------------------------------------------ echo ➡️ Checking curl version... curl --version # ------------------------------------------------------ # 7. Restart PHP-FPM if exists # ------------------------------------------------------ PHP_FPM_SERVICE/etc/init.d/php-fpm-84 if [ -x $PHP_FPM_SERVICE ]; then echo ➡️ Restarting PHP 8.4 FPM... $PHP_FPM_SERVICE restart else echo ⚠️ PHP 8.4 FPM service not found. fi # ------------------------------------------------------ # 8. Validate PHP curl version # ------------------------------------------------------ if command -v php /dev/null 21; then echo ➡️ PHP curl info: php -i | grep -E cURL support|cURL Information|HTTP2 else echo ℹ️ PHP not found, skipping PHP validation. fi echo echo echo Installation complete! echo curl ${CURL_VERSION} (OpenSSL HTTP/2) is now ready! echo sudo ./install_curl_8_17_centos9.sh搞定
返回列表