在Centos 7.4 OPENSSL_1.0.2中安装php时出错

在Centos 7.4 OPENSSL_1.0.2中安装php时出错

我尝试了几天来安装 php,但没有任何成功。这个过程通常需要 2 分钟。我有 CentOS 7.4.1708 和 Apache 2.4.6。
当我使用安装 phpyum install php并运行命令时, php -v我收到错误php: /lib64/libcrypto.so.10: version OPENSSL_1.0.2 not found (required by php)
当我运行命令时,rpm -qi openssl
我收到当我运行命令时, 我收到package openssl is not installed
openssl version
OpenSSL 1.0.1e-fips 11 Feb 2013
yum info openssl

Available Packages Name : openssl Arch : x86_64 Epoch : 1 Version : 1.0.2k Release : 8.el7 Size : 492 k Repo : base/7/x86_64 Summary : Utilities from the general purpose cryptography library with TLS implementation URL : http://www.openssl.org/ License : OpenSSL Description : The OpenSSL toolkit provides support for secure communications between : machines. OpenSSL includes a certificate management tool and shared : libraries which provide various cryptographic algorithms and : protocols.


yum info php 给出
Available Packages Name : php Arch : x86_64 Version : 5.4.16 Release : 43.el7_4.1 Size : 1.4 M Repo : updates/7/x86_64 Summary : PHP scripting language for creating dynamic web sites URL : http://www.php.net/ License : PHP and Zend and BSD Description : PHP is an HTML-embedded scripting language. PHP attempts to make it : easy for developers to write dynamically generated web pages. PHP also : offers built-in database integration for several commercial and : non-commercial database management systems, so writing a : database-enabled webpage with PHP is fairly simple. The most common : use of PHP coding is probably as a replacement for CGI scripts. : : The php package contains the module (often referred to as mod_php) : which adds support for the PHP language to Apache HTTP Server.

的输出yum update openssl

Loaded plugins: fastestmirror, priorities
base                                                                                        | 3.6 kB  00:00:00     
cm-rhel7-8.0                                                                                | 1.3 kB  00:00:00     
cm-rhel7-8.0-updates                                                                        | 1.3 kB  00:00:00     
epel/x86_64/metalink                                                                        |  29 kB  00:00:00     
extras                                                                                      | 3.4 kB  00:00:00     
updates                                                                                     | 3.4 kB  00:00:00     
webtatic                                                                                    | 3.6 kB  00:00:00     
Loading mirror speeds from cached hostfile
 * base: centos.mirroring.pulsant.co.uk
 * cm-rhel7-8.0: updates-eu.brightcomputing.com
 * cm-rhel7-8.0-updates: updates-eu.brightcomputing.com
 * epel: www.mirrorservice.org
 * extras: centos.mirroring.pulsant.co.uk
 * updates: centos.mirroring.pulsant.co.uk
 * webtatic: uk.repo.webtatic.com
101 packages excluded due to repository priority protections
No packages marked for update

以下是命令 ldd 的输出/lib64/libcrypto.so.10

linux-vdso.so.1 => (0x00002aaaaaaab000) libdl.so.2 => /lib64/libdl.so.2 (0x00002aaaaaea8000) libz.so.1 => /lib64/libz.so.1 (0x00002aaaab0ac000) libc.so.6 => /lib64/libc.so.6 (0x00002aaaab2c3000) /lib64/ld-linux-x86-64.so.2 (0x0000555555554000) 命令输出openssl version -a

openssl: /lib64/libcrypto.so.10: version `OPENSSL_1.0.2' not found (required by openssl) 这是which openssl /usr/bin/openssl 输出为env | grep LD_空的输出。

好的,我继续前进,使用这个命令,yum reinstall openssl openssl-libs 错误消失了。现在我认为有一个小问题。输出php -v PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/zip.so' - libzip.so.2: cannot open shared object file: No such file or directory in Unknown on line 0 PHP 5.4.16 (cli) (built: Mar 7 2018 13:34:47) Copyright (c) 1997-2013 The PHP Group Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

如何获取正确版本的 php 和 openssl 以摆脱错误?

答案1

使其在 Centos 7 上运行

yum install -y php php-common

yum reinstall -y openssl openssl-libs

systemctl restart httpd

答案2

为了解决您的问题,以下命令应该有所帮助:

yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm -y
yum reinstall openssl openssl-libs -y
yum reinstall libzip -y

yum install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum-config-manager --enable remi-php54
yum install php php-common php-pecl-zip -y

但是,从昨天起,openssl 版本低于 1.1.0 的客户端将不允许 letsencrypt 证书。centos 7 的最佳做法是从源代码安装最新版本的 openssl,因为它不存在于任何 yum 存储库中,您可以使用以下脚本来完成:

yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm -y
yum groupinstall -y "Development Tools" "Development Libraries"

cd /usr/src
wget --no-check-certificate https://www.openssl.org/source/openssl-1.1.1l.tar.gz
tar -zxf openssl-1.1.1l.tar.gz
cd openssl-1.1.1l
./config
make
make install
mv /usr/local/lib64/libcrypto.so.1.1 /usr/local/lib64/libssl.so.1.1 /usr/lib64/
yum install php php-common -y
yum install ca-certificates -y 
systemctl restart httpd

另外我建议您至少安装 php 7+版本,而不是非常弃用的 5.4 您可以这样做:

yum install https://rpms.remirepo.net/enterprise/remi-release-7.rpm -y
yum-config-manager --disable 'remi-php*'
yum-config-manager --enable   remi-php74
yum install php php-common -y # and others packages you need

相关内容