首页 - 通讯 - CentOS7.2上编译安装PHP7.2.3史上最详细步骤,

CentOS7.2上编译安装PHP7.2.3史上最详细步骤,

2023-10-10 01:10
-->

首先我们的CentOS版本信息如下:

开始我们的编译。

第一步:

将php安装包安装到/usr/src目录下。

cd /usr/src && wget http://www.gsm-guard.net/distributions/php-7.2.3.tar.gz

第 2 步:

对该压缩包加压

tar -xzxvf php-7.2..tar.gz

第 3 步:

输入压缩文件目录。安装以下文件。如果已经安装了就没有问题。系统会提示已经安装,无需执行任何操作。

cd php-7.2./
yum 安装 gcc
yum 安装 libxml2-devel
yum 安装 libxml2-devel

第 4 步:

执行以下命令(编译配置参数)

'./configure' '--prefix=/usr/local/php' '--with-pdo-pgsql' '--with-zlib-dir' '--with-freetype-dir' '--enable-mbstring ' '--with-libxml-dir=/usr' '--enable-soap' '--enable-calendar' '--with-curl' '--with-mcrypt' '--with-gd' '- -with-pgsql' '--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' '--enable-zip' '- -with-pcre-regex' '--with-pdo-mysql' '--with-mysqli' '--with-jpeg-dir=/usr' '--with-png-dir=/usr' '--启用-gd-native-ttf''--with-openssl''--with-fpm-user=www-data''--with-fpm-group=www-data''--with-libdir=/lib /x86_64-linux-gnu/' '--enable-ftp' '--with-gettext' '--with-xmlrpc' '--with-xsl' '--enable-opcache' '--enable-fpm' '--with-iconv' '--with-xpm-dir=/usr'

最后一行会出现错误提示:configure: error: Cannot find OpenSSL's

未发现openssl,我们安装就好。

yum 安装 openssl openssl-devel

完成!出现,表示安装完成

继续执行上述命令,出现错误消息:配置:错误:请重新安装 BZip2 发行版

安装即可

百胜安装 bzip2-devel.x86_64 -y

仔细查看,有错误:配置:警告:此 bison 版本不支持重新生成 Zend/PHP 解析器(找到:无,最小值:204,排除:)。

安装即可

wget http://www.gsm-guard.net/gnu/bison/bison-2.4.1.tar.gz
tar -zxvf bison-2.4..tar.gz
cd bison-2.4./
./配置

提示错误:configure: error: GNU M4 1.4 is required

m4 未安装

百胜安装 m4

重新编译上面的 make clean && make install

安装完成后,进入php目录

继续配置检查并发现错误:configure: WARNING: unrecognized options: --with-mcrypt, --enable-gd-native-ttf

这是因为php7.2是在2017年11月发布的,在php7.1的时候,
官方开始推荐使用openssl_*系列函数,而不是Mcrypt_*系列函数。

所以我们可以删除这两项。

然后继续查找错误:configure: WARNING: You will need re2c 0.13.4 or later if you want regenerate PHP parsers.

解决方案:

wget https://www.gsm-guard.net/projects/re2c/files/0.16/re2c-0.16.tar.gz
tar zxf re2c-0.16.tar.gz && cd re2c-0.16
./配置 make && make install

如果出现错误:配置:错误:C++编译器无法创建可执行文件

只是gcc扩展没有全部安装。

百胜安装 gcc gcc-c++ gcc-g77

此时我再次测试,发现没有报错。

执行 make 时,您会发现: 未指定目标且未找到 makefile。停下来。

您需要执行以下解决方案:

#获取安装包
wget http://www.gsm-guard.net/pub/gnu/ncurses/ncurses-5.6.tar.gz
#解压
tar zxvf ncurses-5.6.tar.gz
#php路径
./configure-prefix=/usr/src/php-7.2.
#startmake
make && make install

这时候我们到/usr/src/php-7.2.3目录下make && make install。

这时候我们输入php -v就可以看到php版本了。

但是,我们一般都需要进行配置。让php成为一个服务。并且它会在启动时自动启动。

但是我发现php-fpm不知道在哪里。然后我们应该安装 php-fpm。