2024-03-06|閱讀時間 ‧ 約 22 分鐘

[PHP] 為PHP中的cURL安裝OpenSSL憑證

此文章同步刊登於我的部落格

一、下載憑證

  1. 點選cacert.pem下載CA certificates extracted from Mozilla
raw-image
  1. 將憑證放置到伺服器的主機上,例如/etc/ssl/certs/cacert.pem


二、設定php.ini

  1. 開啟php.ini,並找到以下兩行
    ;openssl.cafile=
    ;openssl.capath=
  2. 刪除最前面的分號取消註解,並將下載的憑證路徑設定到這兩行上後儲存
    openssl.cafile=/etc/ssl/certs/cacert.pem
    openssl.capath=/etc/ssl/certs/cacert.pem

三、重新啟動Web Server

  1. 重新啟動web server
    # Apache
    systemctl httpd restart

    # Nginx
    systemctl nginx restart
    對於沒有systemd的Linux系統
    # Apache
    service stop httpd
    service start httpd

    # Nginx
    service stop nginx
    service start nginx
  2. 如果是使用php-fpm也要重新啟動
    service stop php7-fpm
    service start php7-fpm
分享至
成為作者繼續創作的動力吧!
主要分享PHP相關的技術文章,包含Laravel與Codeigniter等,也許也會有其他範疇的內容。 歡迎交流~
從 Google News 追蹤更多 vocus 的最新精選內容從 Google News 追蹤更多 vocus 的最新精選內容

發表回應

成為會員 後即可發表留言