openssl 版本过高导致php7.0 安装openssl 失败

/Users/cpm/Downloads/packages/php-5.4.45/ext/openssl/openssl.c:1433:15: error: incomplete definition of type ‘struct X509_extension_st’
p = extension->value->data;
~~~~~~~~~^
/Users/cpm/Downloads/packages/php-5.4.45/ext/openssl/openssl.c:1434:20: error: incomplete definition of type ‘struct X509_extension_st’
length = extension->value->length;

$ curl -O https://www.openssl.org/source/old/1.0.2/openssl-1.0.2u.tar.gz
$ tar xf openssl-1.0.2u.tar.gz
$ cd openssl-1.0.2u
$ ./Configure darwin64-x86_64-cc –prefix=/opt/openssl-1.0.2u
$ make
$ sudo make install



$ ./configure –prefix=/opt/php –with-openssl=/opt/openssl-1.0.2u
$ make
$ sudo make install



https://www.cpming.top/p/mac-php5-configure-openssl-error



在php+redis的遇到“Cannot find OpenSSL’s ”,缺少openssl相关的库,直接安装即可



sudo yum install openssl openssl-devel



遇到“configure: error: mcrypt.h not found. Please reinstall libmcrypt”
提示比较明确,缺少libmcrypt,直接安装即可



sudo yum install libmcrypt



https://github.com/eXolnet/homebrew-deprecated/issues/13



https://github.com/curl/curl/issues/491



http://www.21yunwei.com/archives/2511



https://stackoverflow.com/questions/48108310/installing-php7-0-extensions



[Symfony\Component\Debug\Exception\FatalThrowableError]
Call to undefined function Composer\CaBundle\openssl_x509_parse()



https://www.php.net/manual/zh/function.openssl-x509-parse.php



https://stackoverflow.com/questions/17705244/having-trouble-with-openssl-x509-parse-function



https://stackoverflow.com/questions/10944071/parsing-x509-certificate



https://github.com/jquery/testswarm/pull/319/files
https://github.com/composer/ca-bundle



Script php artisan clear-compiled handling the pre-update-cmd event returned with an error (Laravel 4.1 upgrade)



composer install –no-scripts



https://stackoverflow.com/questions/22855602/script-php-artisan-clear-compiled-handling-the-pre-update-cmd-event-returned-wit



https://github.com/wp-cli/wp-cli/issues/4370



curl -O https://www.openssl.org/source/old/1.0.2/openssl-1.0.2u.tar.gz
tar -zxvf openssl-1.0.2u.tar.gz



./configure –with-openssl=/Users/didi/PhpstormProjects/c/php-src/ext/openssl/openssl-1.0.2u/
不行,必须安装



cd openssl-1.0.2u
./Configure darwin64-x86_64-cc –prefix=/opt/openssl-1.0.2u



make
sudo make install



cd ..
./configure -with-openssl=/opt/openssl-1.0.2u
make -j4
make install
问题解决



$composer config –global secure-http true
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/local/lib/php/extensions/no-debug-non-zts-20151012/openssl.so’ - dlopen(/usr/local/lib/php/extensions/no-debug-non-zts-20151012/openssl.so, 9): initializer function 0x7fff9ac360a0 not in mapped image for /usr/local/lib/php/extensions/no-debug-non-zts-20151012/openssl.so
in Unknown on line 0



Warning: PHP Startup: Unable to load dynamic library ‘/usr/local/lib/php/extensions/no-debug-non-zts-20151012/openssl.so’ - dlopen(/usr/local/lib/php/extensions/no-debug-non-zts-20151012/openssl.so, 9): initializer function 0x7fff9ac360a0 not in mapped image for /usr/local/lib/php/extensions/no-debug-non-zts-20151012/openssl.so
in Unknown on line 0



https://bugs.php.net/bug.php?id=64551



vi ~/.bashrc
export PATH=”$PATH:/opt/openssl-1.0.2u”
source ~/.bashrc



$nm -D /usr/local/lib/php/extensions/no-debug-non-zts-20151012/openssl.so
/Library/Developer/CommandLineTools/usr/bin/nm: /usr/local/lib/php/extensions/no-debug-non-zts-20151012/openssl.so: File format has no dynamic symbol table.



$ otool -L /usr/local/lib/php/extensions/no-debug-non-zts-20151012/openssl.so
/usr/local/lib/php/extensions/no-debug-non-zts-20151012/openssl.so:
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1225.1.1)



https://github.com/mongodb/mongo-php-driver/issues/580

https://github.com/ninenines/erlang.mk/issues/738


可能原因php的 openssl版本和扩展的版本不一致



$ brew list openssl
/usr/local/Cellar/openssl@1.1/1.1.1g/bin/c_rehash
/usr/local/Cellar/openssl@1.1/1.1.1g/bin/openssl
/usr/local/Cellar/openssl@1.1/1.1.1g/include/openssl/ (104 files)
/usr/local/Cellar/openssl@1.1/1.1.1g/lib/libcrypto.1.1.dylib
/usr/local/Cellar/openssl@1.1/1.1.1g/lib/libssl.1.1.dylib
/usr/local/Cellar/openssl@1.1/1.1.1g/lib/engines-1.1/ (2 files)
/usr/local/Cellar/openssl@1.1/1.1.1g/lib/pkgconfig/ (3 files)
/usr/local/Cellar/openssl@1.1/1.1.1g/lib/ (4 other files)
/usr/local/Cellar/openssl@1.1/1.1.1g/share/doc/ (3964 files)
/usr/local/Cellar/openssl@1.1/1.1.1g/share/man/ (3964 files)



$brew uninstall openssl
Error: Refusing to uninstall /usr/local/Cellar/openssl@1.1/1.1.1g
because it is required by mysql and python@3.8, which are currently installed.
You can override this and force removal with:
brew uninstall –ignore-dependencies openssl



$ brew uninstall –ignore-dependencies openssl
Uninstalling /usr/local/Cellar/openssl@1.1/1.1.1g… (8,052 files, 18.4MB)



Warning: The following openssl@1.1 configuration files have not been removed!
If desired, remove them manually with rm -rf:
/usr/local/etc/openssl@1.1
/usr/local/etc/openssl@1.1/cert.pem
/usr/local/etc/openssl@1.1/ct_log_list.cnf
/usr/local/etc/openssl@1.1/ct_log_list.cnf.dist
/usr/local/etc/openssl@1.1/misc
/usr/local/etc/openssl@1.1/misc/CA.pl
/usr/local/etc/openssl@1.1/misc/tsget
/usr/local/etc/openssl@1.1/misc/tsget.pl
/usr/local/etc/openssl@1.1/openssl.cnf
/usr/local/etc/openssl@1.1/openssl.cnf.dist



Warning: The following may be openssl@1.1 configuration files and have not been removed!
If desired, remove them manually with rm -rf:
/usr/local/etc/openssl



https://github.com/kelaberetiv/TagUI/issues/635



sudo rm -rf /opt/openssl-1.0.2u



599 ./config
600 make -j4
601 make install
602 sudo make install



cp libcrypto.pc /usr/local/ssl/lib/pkgconfig
chmod 644 /usr/local/ssl/lib/pkgconfig/libcrypto.pc
cp libssl.pc /usr/local/ssl/lib/pkgconfig
chmod 644 /usr/local/ssl/lib/pkgconfig/libssl.pc
cp openssl.pc /usr/local/ssl/lib/pkgconfig
chmod 644 /usr/local/ssl/lib/pkgconfig/openssl.pc



/usr/local/ssl/bin/openssl version
OpenSSL 1.0.2u 20 Dec 2019



$./configure –with-openssl=/usr/local/ssl/



make失败



$which openssl
/usr/local/bin/openssl



$/usr/local/bin/openssl version
OpenSSL 1.1.1g 21 Apr 2020



$rm -rf /usr/local/bin/openssl



$which openssl
/usr/bin/openssl



$/usr/bin/openssl version
OpenSSL 0.9.8zg 14 July 2015



$rm -rf /usr/local/etc/openssl@1.1



./Configure darwin64-x86_64-cc –prefix=/usr/local/etc/openssl@1.0



mkdir /usr/local/etc/openssl@1.0



$./configure –with-openssl=/usr/local/etc/openssl\@1.0/



$make -j4
/bin/sh /Users/didi/PhpstormProjects/c/php-src/ext/openssl/libtool –mode=compile cc -I. -I/Users/didi/PhpstormProjects/c/php-src/ext/openssl -DPHP_ATOM_INC -I/Users/didi/PhpstormProjects/c/php-src/ext/openssl/include -I/Users/didi/PhpstormProjects/c/php-src/ext/openssl/main -I/Users/didi/PhpstormProjects/c/php-src/ext/openssl -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I/usr/local/etc/openssl@1.0//include -DHAVE_CONFIG_H -g -O2 -c /Users/didi/PhpstormProjects/c/php-src/ext/openssl/openssl.c -o openssl.lo
cc -I. -I/Users/didi/PhpstormProjects/c/php-src/ext/openssl -DPHP_ATOM_INC -I/Users/didi/PhpstormProjects/c/php-src/ext/openssl/include -I/Users/didi/PhpstormProjects/c/php-src/ext/openssl/main -I/Users/didi/PhpstormProjects/c/php-src/ext/openssl -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I/usr/local/etc/openssl@1.0//include -DHAVE_CONFIG_H -g -O2 -c /Users/didi/PhpstormProjects/c/php-src/ext/openssl/openssl.c -fno-common -DPIC -o .libs/openssl.o
/bin/sh /Users/didi/PhpstormProjects/c/php-src/ext/openssl/libtool –mode=link cc -DPHP_ATOM_INC -I/Users/didi/PhpstormProjects/c/php-src/ext/openssl/include -I/Users/didi/PhpstormProjects/c/php-src/ext/openssl/main -I/Users/didi/PhpstormProjects/c/php-src/ext/openssl -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -I/usr/local/etc/openssl@1.0//include -DHAVE_CONFIG_H -g -O2 -o openssl.la -export-dynamic -avoid-version -prefer-pic -module -rpath /Users/didi/PhpstormProjects/c/php-src/ext/openssl/modules openssl.lo xp_ssl.lo -Wl,-rpath,/usr/local/etc/openssl@1.0//lib -L/usr/local/etc/openssl@1.0//lib -lcrypto -lssl -lcrypto
cc ${wl}-flat_namespace ${wl}-undefined ${wl}suppress -o .libs/openssl.so -bundle .libs/openssl.o .libs/xp_ssl.o -L/usr/local/etc/openssl@1.0//lib -lssl -lcrypto -Wl,-rpath -Wl,/usr/local/etc/openssl@1.0//lib
dsymutil .libs/openssl.so || :
creating openssl.la
(cd .libs && rm -f openssl.la && ln -s ../openssl.la openssl.la)
/bin/sh /Users/didi/PhpstormProjects/c/php-src/ext/openssl/libtool –mode=install cp ./openssl.la /Users/didi/PhpstormProjects/c/php-src/ext/openssl/modules
cp ./.libs/openssl.so /Users/didi/PhpstormProjects/c/php-src/ext/openssl/modules/openssl.so
cp ./.libs/openssl.lai /Users/didi/PhpstormProjects/c/php-src/ext/openssl/modules/openssl.la
———————————————————————-
Libraries have been installed in:
/Users/didi/PhpstormProjects/c/php-src/ext/openssl/modules



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 `DYLD_LIBRARY_PATH’ environment variable
    during execution

  • 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.
———————————————————————-



Build complete.
Don’t forget to run ‘make test’.



export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/usr/local/lib



https://github.com/nteract/nteract/issues/1523



vi ~/.bashrc
export DYLD_LIBRARY_PATH =”$DYLD_LIBRARY_PATH:/Users/didi/PhpstormProjects/c/php-src/ext/openssl/modules”



[Composer\Exception\NoSslException]
The openssl extension is required for SSL/TLS protection but is not available. If you can not enable the openssl extension, you can disable this error, at your own risk, by setting the ‘disable-tls’ opti
on to true.



$composer config -g – disable-tls true



composer config –global secure-http false



composer update -no-script



[Symfony\Component\Console\Exception\RuntimeException]   The "--" option does not exist.


composer config -g disable-tls true



cript composer clearcache handling the pre-update-cmd event returned with error code 127



alias 在非交互式shell里不可见



composer.json的 post-script里面的composer 命令找不到composer



解决办法
mv composer.phar /usr/local/bin/
mv /usr/local/bin/composer.phar /usr/local/bin/composer
问题解决



Category php