Centos+Nginx+PHP7.0编译安装(和PHP5.6老版本共存)
来源:http://blog.csdn.net/liuxinmingcode/article/details/50319145
场景
LNMP
当前版本:PHP 5.5.7
为了体验PHP7的速度和性能,加上对新技术的热衷。但是直接切换是不明智的,可能会存在代码不兼容等等问题,因此准备编译安装PHP7,Nginx根据PHP-FastCGI监听端口启用哪个PHP版本。
什么是FastCGI
FastCGI是一个可伸缩地、高速地在HTTP server和动态脚本语言间通信的接口。
大多数流行的HTTP server都支持FastCGI,包括Apache,Nginx和lighttpd等
当然PHP也在其中之列了。
FastCGI接口方式采用C/S结构,可以将HTTP服务器和脚本解析服务器分开,同时在脚本解析服务器上启动一个或多个脚本解析守护进程。当HTTP服务器每次遇到动态程序时,可以将其直接交付给FastCGI进程来执行,然后将其得到的结果返回给浏览器。
PHP版本共存思路
Nginx是通过PHP-FastCGI与PHP进行交互的。而PHP-FastCGI运行后会通过文件、或本地端口两种方式进行监听,在Nginx中配置相应的FastCGI监听端口或文件即实现Nginx请求对PHP的解释。
既然PHP-FastCGI是监听端口和文件的,那就可以让不同版本的PHP-FastCGI同时运行,监听不同的端口或文件,Nginx中根据需求配置调用不同的PHP-FastCGI端口或文件,即可实现不同版本PHP共存了。
编译安装过程
下载解压PHP7
wget -c --no-check-certificate -O php7-src-master.zip https://github.com/php/php-src/archive/master.zipunzip -q php7-src-master.zip && cd php-src-master
- 1
- 2
- 3
- 1
- 2
- 3
编译安装
注意:路径换成自己的。
我是编译到server/php7下面
./buildconf –force
./configure \
–prefix=/alidata/server/php7 \
–exec-prefix=/alidata/server/php7 \
–bindir=/alidata/server/php7/bin \
–sbindir=/alidata/server/php7/sbin \
–includedir=/alidata/server/php7/include \
–libdir=/alidata/server/php7/lib/php \
–mandir=/alidata/server/php7/php/man \
–with-config-file-path=/alidata/server/php7/etc \
–with-MySQL-sock=/tmp/mysql.sock \
–with-mcrypt=/usr/include \
–with-mhash \
–with-openssl \
–with-mysql=shared,mysqlnd \
–with-mysqli=shared,mysqlnd \
–with-pdo-mysql=shared,mysqlnd \
–with-gd \
–with-iconv \
–with-zlib \
–enable-zip \
–enable-inline-optimization \
–enable-sockets \
–enable-soap \
–enable-session \
–with-curl \
–enable-opcache \
–enable-fpm \
–enable-fastcgi \
–with-fpm-user=www \
–with-fpm-group=www \
–disable-fileinfo
执行后结果如下(懒,就不截图了。哈哈):
注:因为之前安装过PHP5版本,所以依赖关系就不需要了。
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
configure: WARNING: unrecognized options: –with-mysql, –enable-fastcgi
编译&&安装
make clean && make && make install
- 1
- 1
执行结果如下:
nstalling shared extensions: /alidata/server/php7/lib/php/extensions/no-debug-non-zts-20151012/
Installing PHP CLI binary: /alidata/server/php7/bin/
Installing PHP CLI man page: /alidata/server/php7/php/man/man1/
Installing PHP FPM binary: /alidata/server/php7/sbin/
Installing PHP FPM config: /alidata/server/php7/etc/
Installing PHP FPM man page: /alidata/server/php7/php/man/man8/
Installing PHP FPM status page: /alidata/server/php7/php/php/fpm/
Installing phpdbg binary: /alidata/server/php7/bin/
Installing phpdbg man page: /alidata/server/php7/php/man/man1/
Installing PHP CGI binary: /alidata/server/php7/bin/
Installing PHP CGI man page: /alidata/server/php7/php/man/man1/
Installing build environment: /alidata/server/php7/lib/php/build/
Installing header files: /alidata/server/php7/include/php/
Installing helper programs: /alidata/server/php7/bin/
program: phpize
program: php-config
Installing man pages: /alidata/server/php7/php/man/man1/
page: phpize.1
page: php-config.1
Installing PEAR environment: /alidata/server/php7/lib/php/php/
设置PHP7的配置文件
php.ini、php-fpm.conf、www.conf和php-fpm脚本
cp php.ini-production /路径/php7/etc/php.ini #复制php.ini配置cp sapi/fpm/init.d.php-fpm /etc/init.d/php7-fpm #复制php-fpm启动脚本##其他配置都在php7/etc/目录下,自行修改配置
- 1
- 2
- 3
- 4
- 5
- 1
- 2
- 3
- 4
- 5
启动php7-fpm
chmod 755 /etc/init.d/php-fpm
/etc/init.d/php7-fpm start
php-fpm支持的操作:
- start,启动PHP的FastCGI进程。
- stop,强制终止PHP的FastCGI进程。
- quit,平滑终止PHP的FastCGI进程。
- restart, 重启PHP的FastCGI进程。
- reload, 重新加载PHP的php.ini。
- logrotate, 重新启用log文件。
添加PHP环境变量
echo -e '\nexport PATH=/路径/php7/bin:/路径/php7/sbin:$PATH\n' >> /etc/profile && source /etc/profile
- 1
- 1
修改Nginx配置,使用PHP7
location ~ .*.(php|php5)?${fastcgi_pass 127.0.0.1:9001; #注意,因为已经有个9000端口服务于PHP5版本了,所以PHP7就用9001了。fastcgi_index index.php;include fcgi.conf;}
- 1
- 2
- 3
- 4
- 5
- 6
- 1
- 2
- 3
- 4
- 5
- 6
Centos+Nginx+PHP7.0编译安装(和PHP5.6老版本共存)相关推荐
- mysql+1.6安装,CentOS 7.0编译安装Nginx1.6.0+MySQL5.6.19+PHP5.5.14方法
这篇文章主要介绍了CentOS 7.0编译安装Nginx1.6.0+MySQL5.6.19+PHP5.5.14方法分享,需要的朋友可以参考下准备篇: 一.配置防火墙,开启80端口.3306端口 Cen ...
- CentOS 7.0编译安装Nginx+MySQL+PHP
转自http://www.centoscn.com/CentosServer/www/2014/0904/3673.html 准备篇: CentOS 7.0系统安装配置图解教程 http://www. ...
- php5.3 php7兼容,Centos搭建PHP7.0.x让php5.3和php7兼容共存教程
先安装php5.3 就不说,说Centos搭建PHP7.0教程: # wget http://php.net/get/php-7.0.4.tar.gz/from/a/mirror 解压安装 # ta ...
- 【转】在CentOS 6.4中编译安装GCC 4.8.1 + GDB 7.6.1
2019独角兽企业重金招聘Python工程师标准>>> 在CentOS 6.4中编译安装GCC 4.8.1 + GDB 7.6.1 一.编译安装gcc 4.8.1 1. 安装gcc ...
- RHEL/CentOS 5.5下编译安装Fcitx(小企鹅输入法)
PS: 因本人家里的台式机比较老,其中的显卡是04年的nvidia mx440,Ubuntu 9.10.10.04与Fedora 12.13都对其支持不好,手动安装显卡驱动后可以用,但很不稳定,X经常 ...
- Nginx基础篇-Nginx 源码编译安装与平滑升级
Nginx基础篇-Nginx 源码编译安装与平滑升级 Nginx官网下载地址 http://nginx.org/ 1.安装依赖包 yum -y install pcre-devel zlib-deve ...
- ClickHouse系列教程七:centos下源码编译安装及报错解决
ClickHouse系列教程: ClickHouse系列教程 参考上一篇博客: ClickHouse系列教程六:源码分析之Debug编译运行 先安装 gcc 8, g++ 8, cmake 3, ni ...
- 在 CentOS 5.4 下编译安装MySQL时
在 CentOS 5.4 下编译安装MySQL时 在 CentOS 5.4 下编译安装MySQL时出错: /bin/rm: cannot remove `libtoolt': No such file ...
- Centos 7 源码编译安装 mysql
文章目录 Centos 7 源码编译安装 mysql 1. 卸载 centos 自带的 mariadb 2. 下载 mysql 3. 安装 mysql 3.1 解压压缩包 3.1.1 自定义解压安装目 ...
最新文章
- mac mysql的安装
- 天津商业大学计算机科学与技术分数线,天津商业大学录取分数线2021是多少分(附历年录取分数线)...
- 学好python工资一般多少钱-Python工资一般是多少 看完吓你一跳
- 正则 至少是数字加英文字符_正则表达式-入门
- 将信息像存银行一样存在数据中心
- 探索比特币源码2-配置Bitcoin Core节点
- linux CentOS7 erlang安装
- vc中把数据库记录表导入Excel
- Ubuntu MySQL 配置 ip binding
- Lua1.0 代码分析 table.c
- 两台服务器centos7.x 直接文件共享,文件挂载 nfs
- ROS 2 Crystal Clemmys版机器人操作系统补充说明
- McAfee Endpoint Security 10.6卸载
- 努力无用论?我不信。。。
- Linux: 李纳斯·托沃兹(Linus Torvalds): “使用KDE”(转)
- 微信小程序 - 数据转excel下载并复制链接
- C语言 写一个函数求两个数的较大值
- 计算机组成原理 | 穿越功耗墙,我们该从哪些方面提升“性能”?
- JWPlayer 使用小记
- 键盘按键与键码的对照表的对照表
热门文章
- HBase不同版本集群之间数据迁移
- Phoenix二级索引(Secondary Indexing)的使用(转:https://www.cnblogs.com/MOBIN/p/5467284.html)
- 05_学生管理系统,xml读写,布局的综合应用
- Strut2和FreeMarker整合时的一些问题
- html块状元素高度,CSS:如何计算块元素的高度?
- 设备树(device tree)学习笔记
- yolov3项目工程
- 语义分割 - 数据集准备
- C++之stdafx.h的用法说明
- TCP/IP协议中的一些常用端口简单讲解