linux centos7.x 编译安装php7.4.2

本文档详细介绍了如何在Linux环境下下载、解压PHP 7.4.20源码,并使用常用编译参数进行编译安装。在编译过程中需要注意依赖项的安装,以及可能出现的错误如`Segmentation fault`。安装成功后,还需配置文件并启动服务。提供了一些编译参数的解释和参考资料链接,以便于理解编译过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

php 官网下载源码

https://www.php.net/downloads

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

具体编译参数解释参考

php官网7.4升级 参数变更 文章地址

https://www.php.net/manual/zh/migration74.other-changes.php#migration74.other-changes.pkg-config

官网超简安装文档

基于Nginxhttps://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

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值