Linux环境PHP5.6升级7.1.8

PHP7和HHVM比较
PHP7的在真实场景的性能确实已经和HHVM相当, 在一些场景甚至超过了HHVM。HHVM的运维复杂, 是多线程模型, 这就代表着如果一个线程导致crash了, 那么整个服务就挂了, 并且它不会自动重启。另外它采用JIT, 那么意味着, 重启以后要预热, 没有预热的情况下, 性能较为糟糕。并且多线程模型调试困难, 这对于追求稳定来说的Web服务来说, 是非常不适合的。

 

Nginx以及PHP7.0之前的版本可以参考此文:Linux环境Nginx安装与调试以及PHP安装

PHP7.0正式版已经在2015年11月份左右发布,目前是PHP7.0.2版本,本人最早是从2015年8月php7的第一个测试版跟起,现在正式版发布。

linux版本:64位CentOS 6.6

Nginx版本:nginx1.8.0

php版本:php-7.0.2

下载

http://php.net/get/php-7.1.8.tar.gz/from/a/mirror

 
建议安装之前先看看安装帮助文件INSTALL
 
解压安装
1
2
3
# tar zxvf php-7.1.8.tar.gz
 
# cd php-7.1.8

首先查看安装帮助

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# ./configure   --help
# ./configure --prefix=/usr/local/php
 --with-curl
 --with-freetype-dir
 --with-gd
 --with-gettext
 --with-iconv-dir
 --with-kerberos
 --with-libdir=lib64
 --with-libxml-dir
 --with-mysqli
 --with-openssl
 --with-pcre-regex
 --with-pdo-mysql
 --with-pdo-sqlite
 --with-pear
 --with-png-dir
 --with-xmlrpc
 --with-xsl
 --with-zlib
 --enable-fpm
 --enable-bcmath
 --enable-libxml
 --enable-inline-optimization
 --enable-gd-native-ttf
 --enable-mbregex
 --enable-mbstring
 --enable-opcache
 --enable-pcntl
 --enable-shmop
 --enable-soap
 --enable-sockets
 --enable-sysvsem
 --enable-xml
 --enable-zip

可能遇到关于--with-xsl模块的报错,删掉--with-xsl 重新执行一遍即可

如果配置错误,需要安装需要的模块,直接yum一并安装依赖库

# yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel MySQL pcre-devel

注意:安装php7beta3的时候有几处配置不过去,需要yum一下,现在php-7.1.8已经不用这样了。
# yum -y install curl-devel
# yum -y install libxslt-devel
 
编译安装
# make &&  make install
 
配置文件
1
2
3
4
# cp php.ini-development /usr/local/php/lib/php.ini
# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
# cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
# cp -R ./sapi/fpm/php-fpm /etc/init.d/php-fpm

需要注意的是php7中www.conf这个配置文件配置phpfpm的端口号等信息,如果你修改默认的9000端口号需在这里改,再改nginx的配置

启动
#  /etc/init.d/php-fpm
 
查看phpinfo()
 
摘自:http://blog.csdn.net/21aspnet/article/details/47708763
           http://blog.csdn.net/unix21/article/details/8544922
转载:https://www.cnblogs.com/cxscode/p/7400452.html
原文地址:https://www.cnblogs.com/lxwphp/p/10232614.html