如何在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

出現這個說明安裝大功告成,恭喜你了

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容