PHP curl 修改配置为 SSL Version => OpenSSL

<?php

PHP curl 修改配置为 SSL Version => OpenSSL ===============================================

一:简介 1:openssl 与 curl 扩展库尽量不要覆盖系统的 /usr/bin 目录下的配置,会影响其他软件的运行 2:先编译php,不使用 --with-curl=DIR 配置,php编译完成后再编译 curl 模块。curl在php资源包ext目录下。 因为编译php时 --with-curl=DIR 指定目录是无效的(存在这种情况)。--with-openssl=DIR 是有效的(也可能是无效的) 所以 -with-curl -with-openssl 在php编译后,再编译模块

二:openssl 下载与安装 1:github 下载 ~]# git clone https://github.com/openssl/openssl.git

2:编译安装 ~]# ./config --prefix=/usr/local/software/openssl # 备注:建议不使用 INSTALL 配置的 --openssldir=/usr/local/ssl ~]# make && make install

3:version ~]# /usr/local/software/openssl/bin/openssl version OpenSSL 1.1.2-dev xx XXX xxxx

三:curl 下载与安装 1:github 与 官网下载 官网: https://curl.haxx.se/download.html github: https://github.com/curl/curl.git

2:编译安装 ~]# ./configure --prefix=/usr/local/software/curl --with-ssl=/usr/local/software/openssl # 备注:注意指定的是 openssl 的编译时指定的目录,而不是 bin/openssl 执行文件 ~]# make && make install

3:version ~]# /usr/local/software/curl/bin/curl --version curl 7.61.1 (x86_64-apple-darwin17.7.0) libcurl/7.61.1 OpenSSL/1.0.2p zlib/1.2.11 libidn2/2.0.5 Release-Date: 2018-09-05 Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp Features: AsynchDNS IDN IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP UnixSockets HTTPS-proxy

四:php curl 扩展安装 1:扩展目录在 php 资源包中 ext 目录下

2:模块编译安装 ~]# /usr/local/software/php71/bin/phpize ~]# ./configure --with-php-config=/usr/local/software/php71/bin/php-config --with-curl=/usr/local/software/curl/ # 备注 --with-curl=DIR 使用curl编译的的目录而不是 bin/curl 执行文件 ~]# /usr/local/software/php71/bin/php php.ini 设置 extension=curl.so

3:version ~]# php -i SSL Version => OpenSSL/1.0.2p ZLib Version => 1.2.11

经验分享 程序员 微信小程序 职场和发展