CentOS7 PHP cURL errno 35, 原因:CentOS7中沒有安裝curl和OpenSSL的最新版


安裝OpenSSL的最新版

話不多說,直接上安裝步驟

#cd /usr/local/src
# 跳過證書獲取失敗
# wget https://www.openssl.org/source/openssl-1.0.2n.tar.gz --no-check-certificate
# tar xzvf openssl-1.0.2n.tar.gz
# cd openssl-1.0.2n
# ./config shared enable-ssl2 enable-ssl3 --prefix=/usr
# make depend
# make
# #確認沒有錯誤
# make test
# make install
# #如果順利的話就好了
# openssl version

進展順利

安裝curl的最新版

這里也大體上就那樣,不過,因為wget curl的文件的時候,SSL通信用其他的方法取得

# cd /usr/local/src
# #如果wget不能用其他的方法下載
# wget https://curl.haxx.se/download/curl-7.58.0.tar.gz
# tar xzvf curl-7.58.0.tar.gz
# cd curl-7.58.0
# ./configure --enable-libcurl-option --with-ssl=/usr --prefix=/usr

./confirure 的輸出結果的一部分如下:

--如果弄錯with-ssl的目錄指定,SSL support的部分變成no。
--libcurl option:也確認一下是enabled吧。

configure: Configured to build curl/libcurl:

  curl version:     7.58.0
  Host setup:       x86_64-pc-linux-gnu
  Install prefix:   /usr
  Compiler:         gcc
  SSL support:      enabled (OpenSSL)
  SSH support:      no      (--with-libssh2)
  zlib support:     enabled
  brotli support:   no      (--with-brotli)
  GSS-API support:  no      (--with-gssapi)
  TLS-SRP support:  enabled
  resolver:         POSIX threaded
  IPv6 support:     enabled
  Unix sockets support: enabled
  IDN support:      no      (--with-{libidn2,winidn})
  Build libcurl:    Shared=yes, Static=yes
  Built-in manual:  enabled
  --libcurl option: enabled (--disable-libcurl-option)
  Verbose errors:   enabled (--disable-verbose)
  SSPI support:     no      (--enable-sspi)
  ca cert bundle:   /etc/pki/tls/certs/ca-bundle.crt
  ca cert path:     no
  ca fallback:      no
  LDAP support:     enabled (OpenLDAP)
  LDAPS support:    enabled
  RTSP support:     enabled
  RTMP support:     no      (--with-librtmp)
  metalink support: no      (--with-libmetalink)
  PSL support:      no      (libpsl not found)
  HTTP2 support:    disabled (--with-nghttp2)
  Protocols:        DICT FILE FTP FTPS GOPHER HTTP HTTPS IMAP IMAPS LDAP LDAPS POP3 POP3S RTSP SMB SMBS SMTP SMTPS TELNET TFTP

然后 make

# make

中途輸出Warning: compression requested but Gzip is not available,這次沒有通過!好像在hugehelp.c上輸出了什么,應該不是嚴重的錯誤……?

然后 make install

# make install

下面顯示輸出結果的一部分。

 /bin/sh ../libtool   --mode=install /usr/bin/install -c   libcurl.la '/usr/lib'
libtool: install: /usr/bin/install -c .libs/libcurl.so.4.5.0 /usr/lib/libcurl.so.4.5.0

(略)

----------------------------------------------------------------------
Libraries have been installed in:
   /usr/lib

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the '-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the 'LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the 'LD_RUN_PATH' environment variable
     during linking
   - use the '-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to '/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

安裝好了, curl -V 不過有錯誤。

curl: error while loading shared libraries: libcurl.so.4: cannot open shared object file: No such file or directory

好像無法讀取庫。

如果用ldd /usr/bin/curl確認的話,確實沒有libcurl.so.4 =>的參照處。但是make install的時候/usr/lib/libcurl.so.4.5.0上寫着安裝了。

用共享庫就好。(http://www.8wave.net/ldconfig.html)

# # 在末尾添加“/usr/lib”
# vim /etc/ld.so.conf.d/lib.conf
# ldconfig

這樣就OK了。

curl -V

輸出結果

curl 7.58.0 (x86_64-pc-linux-gnu) libcurl/7.58.0 OpenSSL/1.0.2n zlib/1.2.3
Release-Date: 2018-01-24
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp 
Features: AsynchDNS IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP UnixSockets HTTPS-proxy 

大功告成!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM