php 官网下载源码
7.4.20地址
https://www.php.net/distributions/php-7.4.20.tar.gz
创建目录 下载并解压
mkdir -p /usr/local/download
wget https://www.php.net/distributions/php-7.4.20.tar.gz
tar -zxvf php-7.4.20.tar.gz && cd php-7.4.20
常用编译参数 复制框
./configure --prefix=/usr/local/php7.4.20 --with-config-file-path=/usr/local/php7.4.20/etc --with-pdo-mysql=/usr/local/mysql --enable-mbstring --with-openssl --enable-sockets --enable-gd --with-jpeg --with-freetype --with-zlib --with-libxml --with-zip --enable-fpm --enable-xml --with-iconv --with-iconv-dir=/usr/local --enable-soap --enable-pcntl --enable-cli --with-curl
查看框
./configure --prefix=/usr/local/php7.4.20 --with-config-file-path=/usr/local/php7.4.20
--with-pdo-mysql=/usr/local/mysql --enable-mbstring --with-openssl
--enable-sockets --enable-ftp --enable-gd --with-jpeg --with-png
--with-freetype --with-zlib --with-libxml --with-zip
--enable-fpm --enable-xml --with-iconv --with-iconv-dir=/usr/local
--enable-soap --enable-pcntl --enable-cli --with-curl
***重要提示
--with-* 参数后一定要确保本机已经安装了此依赖,且依赖名不一定和 --with-这里一致,否则错误很难找,(亲身体会)
编译参数介绍
+--------------------------------------------------------------------+
| License: |
| This software is subject to the PHP License, available in this |
| distribution in the file LICENSE. By continuing this installation |
| process, you are bound by the terms of this license agreement. |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point. |
+--------------------------------------------------------------------+
Thank you for using PHP.
configure: WARNING: unrecognized options: --with-png
如上所示就ok了
安装
make && make install
program: phpize
program: php-config
Installing man pages: /usr/local/php7.4.20/php/man/man1/
page: phpize.1
page: php-config.1
/service/php-7.4.20/build/shtool install -c ext/phar/phar.phar /usr/local/php7.4.20/bin/phar.phar
ln -s -f phar.phar /usr/local/php7.4.20/bin/phar
Installing PDO headers: /usr/local/php7.4.20/include/php/ext/pdo/
[root@VM-0-6-centos php-7.4.20]#
如上代表安装成功
剩下copy配置文件启动就ok
安装过程报错
-lxml2 -lz -lpng15 -ljpeg -lfreetype -lonig -lmysqlclient -lpthread -lm -lrt -ldl -lsqlite3 -lxml2 -lxml2 -lcrypt -lxml2 -lxml2 -lxml2 -lzip -lcrypt -o sapi/cgi/php-cgi
Generating phar.php
/bin/sh: line 1: 18331 Segmentation fault ` if test -x "/service/php-7.4.20/sapi/cli/php"; then /service/php-7.4.20/build/shtool echo -n -- "/service/php-7.4.20/sapi/cli/php -n"; if test "x" != "x"; then /service/php-7.4.20/build/shtool echo -n -- " -d extension_dir=/service/php-7.4.20/modules"; for i in bz2 zlib phar; do if test -f "/service/php-7.4.20/modules/$i.la"; then . /service/php-7.4.20/modules/$i.la; /service/php-7.4.20/build/shtool echo -n -- " -d extension=$dlname"; fi; done; fi; else /service/php-7.4.20/build/shtool echo -n -- "/service/php-7.4.20/sapi/cli/php"; fi;` -n -d 'open_basedir=' -d 'output_buffering=0' -d 'memory_limit=-1' -d phar.readonly=0 /service/php-7.4.20/ext/phar/build_precommand.php > ext/phar/phar.php
make: *** [ext/phar/phar.php] Error 139
Error 139
Error 139 参考链接:https://blog.csdn.net/BookNoteY/article/details/117607409
具体编译参数解释参考
https://www.php.net/manual/zh/migration74.other-changes.php#migration74.other-changes.pkg-config
官网超简安装文档
基于Nginx:https://www.php.net/manual/zh/install.unix.nginx.php
基于Apache:https://www.php.net/manual/zh/install.unix.apache2.php
参数介绍文档(自认为还可以的,就是版本不是很明确)
1.https://www.cnblogs.com/wanglijun/p/8776508.html
2.https://blog.csdn.net/weixin_41282397/article/details/87811111