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

开始我们的编译。

第一步:

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

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

第二步:

加压这个压缩包

tar -xzxvf php-7.2..tar.gz

第三步:

进入压缩后的文件目录。安装如下文件,如果已经安装也没问题,系统会提示已经安装,nothing to do。

cd php-7.2./
yum install gcc
yum install libxml2-devel
yum install libxml2-devel

第四步:

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

'./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' '--enable-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 <evp.h>

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

yum install openssl openssl-devel

出现Complete!则表示安装完成

继续以上命令出现错误提示: configure: error: Please reinstall the BZip2 distribution

安装即可

yum install bzip2-devel.x86_64 -y

仔细看还有错误:configure: WARNING: This bison version is not supported for regeneration of the Zend/PHP parsers (found: none, min: 204, excluded: ).

安装即可

wget http://ftp.gnu.org/gnu/bison/bison-2.4.1.tar.gz
tar -zxvf bison-2.4..tar.gz
cd bison-2.4./
./configure

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

未安装m4

yum install m4

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

安装完成后切入php目录

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

这个是由于php7.2是 17年11月份发行的,在php7.1时,
官方就开始建议用openssl_*系列函数代替Mcrypt_*系列的函数。

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

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

解决:

wget https://sourceforge.net/projects/re2c/files/0.16/re2c-0.16.tar.gz
tar zxf re2c-0.16.tar.gz && cd re2c-0.16
./configure
make && make install

如果出现错误:configure: error: C++ compiler cannot create executables

就是gcc扩展没装全。

yum install gcc gcc-c++ gcc-g77 

至此,再测试,发现已无报错。

当你进行 make时候发现:No targets specified and no makefile found.  Stop.

则需要进行一下方案解决:

#拿到安装包
wget http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.6.tar.gz
#解压
tar zxvf ncurses-5.6.tar.gz
#指向php的路径
./configure -prefix=/usr/src/php-7.2.
#开始make
make && make install

此时,我们再去/usr/src/php-7.2.3目录下make && make install。

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

但是,我们一般还需要做一个配置。让php成为一个服务。并且开机自启。

但是却发现php-fpm不知道咋哪里。 那我们就应该安装php-fpm.

#找找php-fpm
find / -name php-fpm.conf
#没找到就安装
yum install php-fpm php-mysql

做如下的配置

mkdir -p /usr/local/php/etc/
touch /usr/local/php/etc/php-fpm.conf
cp /etc/php-fpm.conf /usr/local/php/etc/php-fpm.conf

同样道理

mkdir -p /usr/local/php/etc/php-fpm.d/
touch /usr/local/php/etc/php-fpm.d/www.conf
cp /etc/php-fpm.d/www.conf /usr/local/php/etc/php-fpm.d/www.conf

继续

mkdir -p /etc/init.d
touch /etc/init.d/php-fpm
cp /usr/src/php-7.2./sapi/fpm/init.d.php-fpm.in /etc/init.d/php-fpm

启动服务并查看

 service php-fpm start
ps aux | grep php-fpm

此时我们的php编译就大功告成。

如下:

-----------------  如果这篇文章帮到了你,或者遇到什么问题,可以在以下留言交流。

CentOS7.2编译安装PHP7.2.3之史上最详细步骤。的更多相关文章

  1. centos7.6编译安装php7.2.11及redis/memcached/rabbitmq/openssl/curl等常见扩展

    centos7.6编译安装php7..11及redis/memcached/rabbitmq/openssl/curl等常见扩展 获取Php的编译参数方法: [root@eus-api-cms-bac ...

  2. centos7下编译安装php-7.0.15(PHP-FPM)

    centos7下编译安装php-7.0.15(PHP-FPM) 一.下载php7源码包 http://php.net/downloads.php 如:php-7.0.15.tar.gz 二.安装所需依 ...

  3. Linux Centos7.2 编译安装PHP7.0.2

    操作环境: 1.系统:Centos7.2 2.服务:Nginx 1.下载PHP7.0.2的安装包解压,编译,安装: $ cd /usr/src/ $ wget http://cn2.php.net/d ...

  4. Centos7.2 编译安装PHP7

    PHP7,编译安装: 环境:centos7.2    (注意:因为我用的nginx, 此配置参数没有考虑到apache,所以不合适需要用apache的朋友照搬过去运行,但是可以参考.)   直接下载P ...

  5. centos7下编译安装php7.3

    一.下载php7.3的源码 https://www.php.net/downloads.php 下载php-7.3.4.tar.gz 二.安装gcc,gcc-c++,kernel-devel yum ...

  6. centos7.6编译安装php7.3

    刚开始搞环境装过集成,发现不好用,后来自己编译安装一些扩展啊设置的都很容易找到. 以前装过5.6.7.0发现不一样,最近出了7.3是php5速度的三倍,那有必要升级一下列. 由于之前安装过老版本,依赖 ...

  7. Centos7源码编译安装PHP7.2(生产环境)

    安装PHP依赖包,否则在编译的过程中可能会出现各种报错 # Centos 安装epel-release源并将系统包更新到最新版本 $ yum install epel-release-y $ yum ...

  8. centos7.6环境编译安装php-7.2.24修复最新 CVE-2019-11043 漏洞

    先编译安装php-7.2.24,然后编译安装扩展 主版本地址地址:https://www.php.net/distributions/php-7.2.24.tar.gz # 编译 php-7.2.24 ...

  9. Centos7 编译安装PHP7

    Centos7 编译安装PHP7 编译安装的方式可以让组件等设置更加合理,但需要你对PHP的代码及各种配置非常的熟悉,以下为大致的安装流程,大家可以参考 1.下载编译工具 yum groupinsta ...

随机推荐

  1. Python数据结构之三——dict(字典)

    Python版本:3.6.2  操作系统:Windows  作者:SmallWZQ 知识源于生活.Python也是如此. 提到字典,我首先想到的是数学大师--高斯. 为何想起他呢?这主要是因为高斯算法 ...

  2. python爬虫(7)——BeautifulSoup

    今天介绍一个非常好用的python爬虫库--beautifulsoup4.beautifulsoup4的中文文档参考网址是:http://beautifulsoup.readthedocs.io/zh ...

  3. 分布式服务dubbo使用

    SOA 服务框架dubbo 节点角色说明: Provider: 暴露服务的服务提供方. Consumer: 调用远程服务的服务消费方. Registry: 服务注册与发现的注册中心. Monitor: ...

  4. Maven下的SpringMVC MyBatis

    从头开始采用Maven管理,Spring.MyBatis.Tomcat. 在配置过程中SQL Server的Jar老是加载不了,解决方案参考前一篇博文. eclipse中已经自带了Maven的插件所以 ...

  5. 备忘录之 —— .bashrc(IC工具篇)

    好久没有使用这些IC工具了,装在自己的虚拟机中的Linux系统里面,现在想要卸载掉,想起之前自己辛辛苦苦的折腾这些工具配置,如果直接删除,感觉未免有点对不起自己的劳动成果,或许以后再也用不到了,就当是 ...

  6. [原创]ubuntu14.04部署ELK+redis日志分析系统

    ubuntu14.04部署ELK+redis日志分析系统 [环境] host1:172.17.0.4 搭建ELK+redis服务 host2:172.17.0.3 搭建logstash+nginx服务 ...

  7. Java经典编程题50道之四十七

    读取7个数(1~50)的整数值,每读取一个值,程序打印出该值个数的*. public class Example47 {    public static void main(String[] arg ...

  8. js “top、clientTop、scrollTop、offsetTop…”

    当要做一些与位置相关的插件或效果的时候,像top.clientTop.scrollTop.offsetTop.scrollHeight.clientHeight.offsetParent...看到这么 ...

  9. pycharm安装,svn使用,远程开发调试,接口测试,连接服务器

    磨刀不误砍柴工,配置完美的编辑器,在开发时,能帮助我们节约大量的时间成本,从而是我们的精力放在业务逻辑实现上面! 接下来将介绍 使用pyhcarm如何使用svn,远程开发调试,接口测试,已经连接远程服 ...

  10. ajax的缺点

    平时我们大多注意的都是ajax给我们所带来的好处诸如用户体验的提升.对ajax所带来的缺陷有所忽视. 下面所阐述的ajax的缺陷都是它先天所产生的. 1.ajax干掉了back按钮,即对浏览器后退机制 ...