Ubuntu 22.04 编译安装 PHP 7.4.33 报错:make: *** [Makefile:749: ext/openssl/openssl.lo] Error 1

 

下载openssl1.1.1  https://openssl-library.org/source/old/1.1.1/index.html

安装低版本OpenSSL
wget https://github.com/openssl/openssl/releases/download/OpenSSL_1_1_1w/openssl-1.1.1w.tar.gz
tar zxvf openssl-1.1.1w.tar.gz
cd openssl-1.1.1w
./config --prefix=/usr/local/openssl --shared
make && make install
编译php时指定openssl路径
--with-openssl=/opt/build
最终编译命令
./configure --prefix=/usr/local/php-7.4 --with-config-file-path=/usr/local/php-7.4/etc --with-openssl=/opt/build --with-zlib-dir --with-freetype --enable-mbstring --enable-soap --enable-calendar --with-curl --with-zlib --enable-gd  --disable-rpath --enable-inline-optimization --with-bz2 --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --enable-exif --enable-bcmath --with-mhash --with-zip --with-pdo-mysql --with-mysqli --with-mysql-sock=/var/run/mysqld/mysqld.sock --with-jpeg --with-openssl --with-fpm-user=www --with-fpm-group=www --with-libdir=/lib/x86_64-linux-gnu --enable-ftp  --with-kerberos --with-gettext --with-xmlrpc --with-xsl --enable-opcache --enable-intl --with-pear --enable-fpm

 编译安装

make install
Installing shared extensions:     /usr/local/php-7.4/lib/php/extensions/no-debug-non-zts-20190902/
Installing PHP CLI binary:        /usr/local/php-7.4/bin/
Installing PHP CLI man page:      /usr/local/php-7.4/php/man/man1/
Installing PHP FPM binary:        /usr/local/php-7.4/sbin/
Installing PHP FPM defconfig:     /usr/local/php-7.4/etc/
Installing PHP FPM man page:      /usr/local/php-7.4/php/man/man8/
Installing PHP FPM status page:   /usr/local/php-7.4/php/php/fpm/
Installing phpdbg binary:         /usr/local/php-7.4/bin/
Installing phpdbg man page:       /usr/local/php-7.4/php/man/man1/
Installing PHP CGI binary:        /usr/local/php-7.4/bin/
Installing PHP CGI man page:      /usr/local/php-7.4/php/man/man1/
Installing build environment:     /usr/local/php-7.4/lib/php/build/
Installing header files:          /usr/local/php-7.4/include/php/
Installing helper programs:       /usr/local/php-7.4/bin/
  program: phpize
  program: php-config
Installing man pages:             /usr/local/php-7.4/php/man/man1/
  page: phpize.1
  page: php-config.1
Installing PEAR environment:      /usr/local/php-7.4/lib/php/
[PEAR] Archive_Tar    - installed: 1.4.14
[PEAR] Console_Getopt - installed: 1.4.3
[PEAR] Structures_Graph- installed: 1.1.1
[PEAR] XML_Util       - installed: 1.4.5
warning: pear/PEAR dependency package "pear/Archive_Tar" installed version 1.4.14 is not the recommended version 1.4.4
[PEAR] PEAR           - installed: 1.10.13
Wrote PEAR system config file at: /usr/local/php-7.4/etc/pear.conf
You may want to add: /usr/local/php-7.4/lib/php to your php.ini include_path
/opt/php-7.4.32/build/shtool install -c ext/phar/phar.phar /usr/local/php-7.4/bin/phar.phar
ln -s -f phar.phar /usr/local/php-7.4/bin/phar
Installing PDO headers:           /usr/local/php-7.4/include/php/ext/pdo/

 systemctl status php-7.4-fpm.service 启动异常

Dec 30 21:27:57 iZbp167tleyjg1lr7zw9qvZ systemd[1]: Started The PHP 7.4 FastCGI Process Manager.
Dec 30 21:27:57 iZbp167tleyjg1lr7zw9qvZ php-fpm[408017]: /usr/local/php-7.4/sbin/php-fpm: error while loading shared libraries: libssl.so.1.1: cannot open shar>
Dec 30 21:27:57 iZbp167tleyjg1lr7zw9qvZ systemd[1]: php-7.4-fpm.service: Main process exited, code=exited, status=127/n/a
Dec 30 21:27:57 iZbp167tleyjg1lr7zw9qvZ systemd[1]: php-7.4-fpm.service: Failed with result 'exit-code'.

用命令查询需要的链接库

sudo find / -name libssl.so.1.1
/snap/core20/2434/usr/lib/x86_64-linux-gnu/libssl.so.1.1
/snap/core20/1405/usr/lib/x86_64-linux-gnu/libssl.so.1.1
/usr/lib64/libssl.so.1.1
/usr/lib/x86_64-linux-gnu/libssl.so.1.1
/opt/build/lib/libssl.so.1.1
/opt/openssl-1.1.1w/libssl.so.1.1

创建软连接【ln -s 源文件 目标文件】

ln -s /opt/openssl-1.1.1w/libssl.so.1.1 /usr/lib/x86_64-linux-gnu/libssl.so.1.1
ln -s /opt/openssl-1.1.1w/libcrypto.so.1.1 /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1

 

posted @ 2024-12-30 21:09  Tinywan  阅读(23)  评论(0编辑  收藏  举报