git “libcrypto.so.1.0.0:未找到版本‘OPENSSL_1.0.1’”期间 shell_exec

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/37802196/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 12:03:22  来源:igfitidea点击:

"libcrypto.so.1.0.0: version 'OPENSSL_1.0.1' not found " during shell_exec

phpgitgithubsshopenssl

提问by Sidriel

I'm running into a bit of a weird issue in PHP using shell_exec to run git commands. This is a brand new image of Ubuntu 16.x LTS with only a copy of Lampp installed and the git packages. Within a php script which I intend to webhook to, running shell_exec('/usr/bin/git pull 2>&1')prints out the following error.

我在 PHP 中使用 shell_exec 运行 git 命令时遇到了一个奇怪的问题。这是 Ubuntu 16.x LTS 的全新映像,仅安装了 Lampp 的副本和 git 包。在我打算 webhook 的 php 脚本中,运行会shell_exec('/usr/bin/git pull 2>&1')打印出以下错误。

ssh: /opt/lampp/lib/libcrypto.so.1.0.0: version 'OPENSSL_1.0.1' not found (required by ssh)
fatal: Could not read from remote repository.`

I can pull the repository using git pullfrom the command line and that the user running apache has ownership of all files in the htdocs directory.

我可以git pull从命令行使用拉取存储库,并且运行 apache 的用户拥有 htdocs 目录中所有文件的所有权。

openssl version -aresults in the following:

openssl version -a结果如下:

OpenSSL 1.0.2g-fips  1 Mar 2016
built on: reproducible build, date unspecified
platform: debian-amd64
options:  bn(64,64) rc4(16x,int) des(idx,cisc,16,int) blowfish(idx)
compiler: cc -I. -I.. -I../include  -fPIC -DOPENSSL_PIC -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN
-DHAVE_DLFCN_H -m64 -DL_ENDIAN -g -O2 -fstack-protector-strong -Wformat -Werror=format-security
-Wdate-time -D_FORTIFY_SOURCE=2 -Wl,-Bsymbolic-functions -Wl,-z,relro -Wa,--noexecstack -Wall
-DMD32_REG_T=int -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5
-DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM
-DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -DECP_NISTZ256_ASM
OPENSSLDIR: "/usr/lib/ssl"

Is this an issue with the Lamp 5.6.21, or is this an issue with my setup?

这是 Lamp 5.6.21 的问题,还是我的设置的问题?

回答by Roman Khimov

So you have XAMPP installed into /opt/lamppand trying to run native (as in coming from Ubuntu, not XAMPP) git via shell_exec(). What is the environment this shell runs in? It's the environment that XAMPP uses with LD_LIBRARY_PATHset /opt/lampp/lib, which is absolutely needed for all XAMPP components (because they're built to use these libraries from /opt/lampp/lib). Then git inherits this same environment and (although it has perfect openssl library from Ubuntu somewhere in /lib/x86_64-linux-gnu) tries to use libraries from /opt/lampp/lib, bang.

因此,您已安装 XAMPP/opt/lampp并尝试通过.git运行本机(如来自 Ubuntu,而不是 XAMPP)git shell_exec()。这个shell运行的环境是什么?这是 XAMPP 与LD_LIBRARY_PATHset 一起使用的环境/opt/lampp/lib,这是所有 XAMPP 组件绝对需要的(因为它们是为使用这些来自 的库而构建的/opt/lampp/lib)。然后 git 继承了这个相同的环境,并且(尽管它在 Ubuntu 的某个地方有完美的 openssl 库/lib/x86_64-linux-gnu)尝试使用来自/opt/lampp/lib, bang 的库。

What you need is just to clear LD_LIBRARY_PATHenvironment variable prior to git invocation, like:

您只需要LD_LIBRARY_PATH在 git 调用之前清除环境变量,例如:

$oldldpath = getenv('LD_LIBRARY_PATH');
putenv("LD_LIBRARY_PATH=");
shell_exec('/usr/bin/git pull 2>&1');
putenv("LD_LIBRARY_PATH=$oldldpath");