如何在centos6.8编译php7.1.10

目标:centos6.8上编译php7.1.10

问题拆解:

1.准备编译的centos6.8系统(百度云地址)

2.编译的源代码php7.1.10(php7.1.10下载地址)

3.安装编译的编译工具(安装编译工具的YUM仓库)

4.编译php7.1.10的各个模块

5.配置php并且启动验证


       这次我们的主要目标是教会大家编译安装php7.1.10,所以小编默认大家都有centos6.8的环境和从我们提供的地址下载好了相关软件,现在开启我们愉快的旅程吧!

安装下载好的repoforge的仓库

[root@localhost local]# rpm -ivh rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm

Preparing...                ########################################### [100%]

package rpmforge-release-0.5.3-1.el6.rf.x86_64 is already installed

安装编译需要的开发包

[root@localhost local]# yum install -y "@Development tools"

Loaded plugins: fastestmirror

Setting up Install Process

Loading mirror speeds from cached hostfile

epel/metalink             

......(省略无关信息)

Package flex-2.5.35-9.el6.x86_64 already installed and latest version

Package gcc-4.4.7-18.el6.x86_64 already installed and latest version

Package redhat-rpm-config-9.0.3-51.el6.centos.noarch already installed and latest version

Package rpm-build-4.8.0-55.el6.x86_64 already installed and latest version

Package 1:make-3.81-23.el6.x86_64 already installed and latest version

Package patch-2.6-6.el6.x86_64 already installed and latest version

Package 1:pkgconfig-0.23-9.1.el6.x86_64 already installed and latest version

Package gettext-0.17-18.el6.x86_64 already installed and latest version

Package automake-1.11.1-4.el6.noarch already installed and latest version

Package bison-2.4.1-5.el6.x86_64 already installed and latest version

Package libtool-2.2.6-15.5.el6.x86_64 already installed and latest version

Package autoconf-2.63-5.1.el6.noarch already installed and latest version

Package gcc-c++-4.4.7-18.el6.x86_64 already installed and latest version

Package binutils-2.20.51.0.2-5.47.el6_9.1.x86_64 already installed and latest version

Package patchutils-0.3.1-3.1.el6.x86_64 already installed and latest version

Package byacc-1.9.20070509-7.el6.x86_64 already installed and latest version

Package indent-2.2.10-7.el6.x86_64 already installed and latest version

Package systemtap-2.9-7.el6.x86_64 already installed and latest version

Package diffstat-1.51-2.el6.x86_64 already installed and latest version

Package elfutils-0.164-2.el6.x86_64 already installed and latest version

Package cvs-1.11.23-16.el6.x86_64 already installed and latest version

Package rcs-5.7-37.el6.x86_64 already installed and latest version

Package subversion-1.6.11-15.el6_7.x86_64 already installed and latest version

Package gcc-gfortran-4.4.7-18.el6.x86_64 already installed and latest version

Package 1:doxygen-1.6.1-6.el6.x86_64 already installed and latest version

Package intltool-0.41.0-1.1.el6.noarch already installed and latest version

Package git-1.7.1-9.el6_9.x86_64 already installed and latest version

Package ctags-5.8-2.el6.x86_64 already installed and latest version

Package cscope-15.6-7.el6.x86_64 already installed and latest version

Package swig-1.3.40-6.el6.x86_64 already installed and latest version

Warning: Group development does not have any packages.

Nothing to do

安装编译PHP模块各个开发包

[root@localhost local]# yum install -y libxml2-devel  libjpeg-devel libpng-devel freetype-devel openssl-devel  libcurl-devel libmcrypt-devel

Loaded plugins: fastestmirror

Setting up Install Process

Loading mirror speeds from cached hostfile

* base: mirrors.sohu.com

* epel: mirrors.tuna.tsinghua.edu.cn

* extras: mirrors.sohu.com

* rpmforge: mirrors.tuna.tsinghua.edu.cn

* updates: mirrors.sohu.com

Package libxml2-devel-2.7.6-21.el6_8.1.x86_64 already installed and latest version

Package libjpeg-turbo-devel-1.2.1-3.el6_5.x86_64 already installed and latest version

Package 2:libpng-devel-1.2.49-2.el6_7.x86_64 already installed and latest version

Package freetype-devel-2.3.11-17.el6.x86_64 already installed and latest version

Package openssl-devel-1.0.1e-57.el6.x86_64 already installed and latest version

Package libcurl-devel-7.19.7-53.el6_9.x86_64 already installed and latest version

Package libmcrypt-devel-2.5.8-9.el6.x86_64 already installed and latest version

Nothing to do

解压缩php-7.1.10.tar.gz

[root@localhost local]# tar xf php-7.1.10.tar.gz

[root@localhost local]# ls

bin  games  include  jdk1.7.0_75  jdk-7u75-linux-i586.tar_0.gz  lib  lib64  libexec  php7  php-7.1.10  php-7.1.10.tar.gz  pingan  rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm  sbin  share  src  var  zookeeper-3.4.6  zookeeper-3.4.6.tar.gz

开始编译php-7.1.10

[root@localhost php-7.1.10]# ./configure --prefix=/usr/local/php7 --exec-prefix=/usr/local/php7 --bindir=/usr/local/php7/bin --sbindir=/usr/local/php7/sbin --includedir=/usr/local/php7/include --libdir=/usr/local/php7/lib/php --mandir=/usr/local/php7/php/man --with-config-file-path=/usr/local/php7/etc --with-pdo-mysql  --with-mysqli  --with-mcrypt=/usr/include --with-mhash --with-openssl --with-zlib --enable-zip  --with-gd --with-iconv --with-zlib --enable-zip --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-mbregex --enable-mbstring --enable-ftp --enable-gd-native-ttf --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --without-pear --with-gettext --enable-session --with-curl --with-jpeg-dir --with-freetype-dir --enable-opcache --enable-fpm  --with-fpm-user=apache --with-fpm-group=apache --without-gdbm --disable-fileinfo  --enable-maintainer-zts

checking for grep that handles long lines and -e... /bin/grep

checking for egrep... /bin/grep -E

checking for a sed that does not truncate output... /bin/sed

checking build system type... x86_64-unknown-linux-gnu

checking host system type... x86_64-unknown-linux-gnu

checking target system type... x86_64-unknown-linux-gnu

checking for cc... cc

checking whether the C compiler works... yes

checking for C compiler default output file name... a.out

checking for suffix of executables...

checking whether we are cross compiling... no

checking for suffix of object files... o

checking whether we are using the GNU C compiler... yes

checking whether cc accepts -g... yes

checking for cc option to accept ISO C89... none needed

checking how to run the C preprocessor... cc -E

checking for icc... no

.........(省略中间过程)

creating libtool

appending configuration tag "CXX" to libtool

Generating files

configure: creating ./config.status

creating main/internal_functions.c

creating main/internal_functions_cli.c

+--------------------------------------------------------------------+

| 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.

config.status: creating php7.spec

config.status: creating main/build-defs.h

config.status: creating scripts/phpize

config.status: creating scripts/man1/phpize.1

config.status: creating scripts/php-config

config.status: creating scripts/man1/php-config.1

config.status: creating sapi/cli/php.1

config.status: creating sapi/fpm/php-fpm.conf

config.status: creating sapi/fpm/www.conf

config.status: creating sapi/fpm/init.d.php-fpm

config.status: creating sapi/fpm/php-fpm.service

config.status: creating sapi/fpm/php-fpm.8

config.status: creating sapi/fpm/status.html

config.status: creating sapi/cgi/php-cgi.1

config.status: creating ext/phar/phar.1

config.status: creating ext/phar/phar.phar.1

config.status: creating main/php_config.h

config.status: executing default commands

(看到这样的结尾,恭喜你编译成功了)

最后编译安装

[root@localhost php-7.1.10]# make && make install

配置php-fpm

[root@localhost php-7.1.10]# cp -r php.ini-production  /usr/local/php7/etc/php.ini

[root@localhost php-7.1.10]# cp /usr/local/php7/etc/php-fpm.conf.default  /usr/local/php7/etc/php-fpm.conf

[root@localhost php-7.1.10]# cp /usr/local/php7/etc/php-fpm.d/www.conf.default  /usr/local/php7/etc/php-fpm.d/www.conf

Tips:

[root@localhost php-7.1.10]# useradd www 

把/usr/local/php7/etc/php-fpm.d/www.conf用户apache改成www

最后启动验证php-fpm

[root@localhost php-7.1.10]# /usr/local/php7/sbin/php-fpm

检验是否启动成功

[root@localhost php-7.1.10]# ps -ef|grep php

root      8518 28358  0 14:00 pts/1    00:00:00 grep php

root    27753    1  0 Oct16 ?        00:00:02 php-fpm: master process (/usr/local/php7/etc/php-fpm.conf)

www      27754 27753  0 Oct16 ?        00:00:01 php-fpm: pool www

www      27755 27753  0 Oct16 ?        00:00:01 php-fpm: pool www

www      28121 27753  0 Oct16 ?        00:00:01 php-fpm: pool www

出现这个说明安装大功告成,恭喜你了

你可能感兴趣的:(如何在centos6.8编译php7.1.10)