“libcrypto.so.1.0.0:未找到版本'OPENSSL_1.0.1'”在shell_exec期间 [英] "libcrypto.so.1.0.0: version 'OPENSSL_1.0.1' not found " during shell_exec
问题描述
我在使用shell_exec运行git命令时遇到了一个奇怪的问题。这是Ubuntu 16.x LTS的全新映像,仅安装了Lampp副本和git软件包。在我打算webhook的php脚本中,运行 shell_exec('/ usr / bin / git pull 2>& 1')
会打印出以下错误。 p>
ssh:/opt/lampp/lib/libcrypto.so.1.0.0:version'OPENSSL_1 .0.1'找不到(由ssh要求)
致命:无法从远程存储库读取。
我可以从命令行使用 git pull
来获取存储库,并且运行apache的用户拥有htdocs目录中所有文件的所有权。
openssl版本-a
会产生以下结果:
OpenSSL 1.0.2g-fips 2016年3月1日
基于:可重复构建,未指定日期
平台:debian-amd64
选项:bn (64,64)rc4(16x,int)des(idx,cisc,16,int)blowfish(idx)
编译器: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 =格式安全性
-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
这是Lamp 5.6.21的问题,还是这是我的设置问题?
解决方案因此,您将XAMPP安装到
/ opt / lampp
中并试图运行本机(如来自Ubuntu, XAMPP)git通过shell_exec()
。这个shell运行的环境是什么?这是XAMPP与LD_LIBRARY_PATH
set/ opt / lampp / lib
一起使用的环境,这对于所有XAMPP组件都是绝对需要的(因为它们被构建为使用/ opt / lampp / lib
中的这些库)。然后,git继承这个相同的环境,并且(尽管它有完美的openssl库,从Ubuntu的某个地方/ lib / x86_64-linux-gnu
)尝试使用来自/ opt / lampp / lib
,bang。
您只需清除
LD_LIBRARY_PATH $ c git调用之前的$ c>环境变量,如:
$ oldldpath = getenv('LD_LIBRARY_PATH');
putenv(LD_LIBRARY_PATH =);
shell_exec('/ usr / bin / git pull 2>& 1');
putenv(LD_LIBRARY_PATH = $ oldldpath);
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.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 pull
from the command line and that the user running apache has ownership of all files in the htdocs directory.
openssl version -a
results in the following: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?
解决方案So you have XAMPP installed into
/opt/lampp
and trying to run native (as in coming from Ubuntu, not XAMPP) git viashell_exec()
. What is the environment this shell runs in? It's the environment that XAMPP uses withLD_LIBRARY_PATH
set/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.What you need is just to clear
LD_LIBRARY_PATH
environment variable prior to git invocation, like:$oldldpath = getenv('LD_LIBRARY_PATH'); putenv("LD_LIBRARY_PATH="); shell_exec('/usr/bin/git pull 2>&1'); putenv("LD_LIBRARY_PATH=$oldldpath");
这篇关于“libcrypto.so.1.0.0:未找到版本'OPENSSL_1.0.1'”在shell_exec期间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!