1.安装php7.0


下载

# wget  http://cn2.php.net/distributions/php-7.0.4.tar.gz

解压安装
# tar zxvf php-7.0.4.tar.gz
# cd php-7.0.4
首先查看安装帮助
# ./configure   --help
设置配置
./configure \
--prefix=/usr/local/php7 \
--exec-prefix=/usr/local/php7 \
--with-config-file-path=/usr/local/php7/etc \
--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 \
--with-zlib-dir \
--with-mhash \
--with-mcrypt \
--with-openssl-dir \
--with-jpeg-dir \
--enable-gd-jis-conv \
 --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-maintainer-zts \
--enable-zip

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

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

# yum -y install curl-devel
# yum -y install libxslt-devel
编译安装
# make &&  make install
1.设置配置文件
# cp php.ini-production /usr/local/php7/etc/php.ini  
php.ini-development 适合开发测试,如本地测试环境, php.ini-production拥有较高的安全性设定,适合服务器上线运营当产品。一般修改php.ini-production为php.ini,安全性更高,确保测试环境(本地)与正式环境(线上)一致
# cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf
# cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf
# cp ./sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
2.加入服务
# chmod +x /etc/init.d/php-fpm
# chkconfig --add php-fpm
需要注意的是php7中www.conf这个配置文件配置phpfpm的端口号等信息,如果你修改默认的9000端口号需在这里改,再改nginx的配置
启动
#  /etc/init.d/php-fpm start
安装Memcached扩展
#需要安装libmemcached最新版本(所需组件)
wget https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz
tar -zxvf libmemcached-1.0.18.tar.gz
cd libmemcached-1.0.18
./configure --prefix=/usr/local/libmemcached
make && make install
#安装memcached扩展
git clone https://github.com/php-memcached-dev/php-memcached -b php7
cd php-memcached
phpize (注意这里必须在php-memcached目录中执行 换句话说就是必须在扩展所在的目录中执行 其他扩展也一样)
./configure --with-libmemcached-dir=/usr/local/libmemcached --disable-memcached-sasl --with-php-config=/usr/local/php7/bin/php-config
make && make install

vi /usr/local/php7/etc/php.ini

   添加 extension= /usr/local/php7/lib/php/extensions/no-debug-zts-20151012/memcached.so

2.安装nginx

查看nginx相关信息

yum list | grep nginx
collectd-nginx.x86_64                        4.10.9-1.el6                   epel
munin-nginx.noarch                           2.0.25-2.el6                   epel
nginx.x86_64                                 1.0.15-11.el6                  epel
nginx-filesystem.noarch                      1.0.15-11.el6                  epel
owncloud-nginx.noarch                        7.0.5-2.el6                    epel
yum info nginx
Loaded plugins: security
Available Packages
Name        : nginx
Arch        : x86_64
Version     : 1.0.15
Release     : 11.el6
Size        : 404 k
Repo        : epel
Summary     : A high performance web server and reverse proxy server
URL         : http://nginx.org/
License     : BSD
Description : Nginx is a web server and a reverse proxy server for HTTP, SMTP, POP3 and: IMAP protocols, with a strong focus on high concurrency, performance and: low memory usage.

发现版本很低,于是追加 nginx 的 yum 仓库,创建一个文件 /etc/yum.repos.d/nginx.repo,并将下面的内容复制进去

[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1

编辑并保存/etc/yum.repos.d/nginx.repo文件后,在命令行下执行

yum list | grep nginx
collectd-nginx.x86_64                      4.10.9-1.el6                 epel
munin-nginx.noarch                         2.0.25-2.el6                 epel
nginx.x86_64                               1.6.3-1.el6.ngx              nginx
nginx-debug.x86_64                         1.6.3-1.el6.ngx              nginx
nginx-debuginfo.x86_64                     1.6.3-1.el6.ngx              nginx
nginx-filesystem.noarch                    1.0.15-11.el6                epel
nginx-nr-agent.noarch                      2.0.0-7.el6.ngx              nginx
owncloud-nginx.noarch                      7.0.5-2.el6                  epel

发现最新的稳定版1.6.3,于是直接执行

yum install nginx -y

安装完成,下面直接就可以启动Nginx了:

/etc/init.d/nginx start
Starting nginx:                                            [  OK  ]

现在Nginx已经启动了,直接访问服务器就能看到Nginx欢迎页面了的。
Nginx的命令以及配置文件位置:

/etc/init.d/nginx start # 启动Nginx服务
/etc/init.d/nginx stop # 停止Nginx服务
/etc/nginx/nginx.conf # Nginx配置文件位置
3.整合Nginx与PHP
Nginx自己并不处理动态网页的请求,而且Nginx将得到的动态请求转交给PHP,我们打开Nginx的配置文件看一下
 vi /etc/nginx/conf.d/default.conf       //标的部分是我们后面要修改的
看上图,Nginx已经知道怎么把得到的请求传达给PHP,Nginx在得到*.php请求时,会把请求通过9000端口传给PHP。下面我们把这些注释给去掉即可,如下图
如上图所示,我们在前面已经看到过Nginx是通过本机的9000端口将PHP请求转发给PHP的,而上图我们可以看到PHP自己是从本机的9000端口侦听数据 ,Nginx与PHP通过本机的9000端口完成了数据请求。
4.测试
我们在nginx的配置文件里面已经定义了PHP网站的存放路径,路径是/usr/share/nginx/html
下面我们在这个目录下新建一个PHP页面测试网页,文件名为test.php,内容如下
<?php
phpinfo();
?>

关闭php

killall php-fpm

php重启

/usr/local/php/sbin/php-fpm &

关闭nginx

/usr/sbin/nginx -s stop   //关闭服务器

重启nginx

/usr/sbin/nginx  开启服务器

重启PHP与nginx后  我们在浏览器中输入http://localhost/test.php,出现如下界面算成功

Linux安装配置php7+nginx相关推荐

  1. php7.0搭配nginx,Linux安装配置php7.0+nginx

    2.安装nginx 查看nginx相关信息 yum list | grep nginx collectd-nginx.x86_64 4.10.9-1.el6 epel munin-nginx.noar ...

  2. linux php7 mongodb,CentOS 7下安装配置PHP7跟LAMP及MongoDB和Redis

    CentOS 7下安装配置PHP7跟LAMP及MongoDB和Redis 我是想能yum就yum,所有软件的版本一直会升级,注意自己当时的版本是不是已经更新了. 首先装CentOS 7 装好cento ...

  3. linux系统数据库服务器配置,Linux安装配置MariaDB数据库全程详解

    MariaDB是采用Maria存储引擎的MySQL分支版本,在很多方面强于MySQL,那么在Linux下如何安装MariaDB数据库呢?下面小编就给大家介绍下Linux安装配置MariaDB数据库的方 ...

  4. Linux安装及卸载Nginx

    Linux安装及卸载Nginx CentOS7 安装 1)安装所需插件 gcc安装 pcre.pcre-devel安装 zlib安装 openssl安装 2)压缩包安装nginx 下载安装包 解压 编 ...

  5. Linux 安装、卸载Nginx详细教程

    Linux 安装.卸载Nginx详细教程 Linux版本的Nginx推荐使用源代码安装. 1. 环境准备 为了编译Nginx源代码,我们需要标准的GCC编译器.GCC的全称为GNUCompiler C ...

  6. Linux安装配置Java1.8开发环境

    Linux安装配置Java开发环境 1 下载Java安装包 链接:https://pan.baidu.com/s/1MzFG9k1Uij_QDnsMA9epNg 提取码:2l26 2 上传JDK到Li ...

  7. Tiny Core Linux 安装配置

    Tiny Core Linux 安装配置 目标 通过最小的命令行版 Tiny Core Linux 系统光盘安装 Tiny Core Linux 桌面环境,设置中文界面,安装输入法,设置分辨率. 所有 ...

  8. Linux安装配置Git

    Linux安装配置Git 依赖库安装 yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel yum ins ...

  9. linux系统配置php环境,Linux安装配置php环境2种方法linux操作系统 -电脑资料

    本文章来给大家介绍两种在linux中配置安装php方法,希望此方法对各位同学会有所帮助哦, php安装配置方法一 1.获取安装文件: http://www.php.net/downloads.php  ...

最新文章

  1. Java线程详解(11)-线程池
  2. 【收藏】使用springboot构建rest api远程提交spark任务
  3. 机器学习:从感知机模型体会随机梯度下降
  4. python中如何标识语句块_如何用python在一个块中编写多个try语句?
  5. RocketMQ(三)—— 集群模式的说明
  6. 购买域名以及申请证书
  7. 如何在 macOS 中锁定文件和文件夹?
  8. FISCO BCOS 区块链 设置交易最晚处理区块高度
  9. c# gerber文件读取_PCB加工中Gerber文件的解析及其图形绘制和分割的研究
  10. python实现 猴子摘香蕉
  11. 新知实验室TRTC初探
  12. php小说网站windows慢,终于找到WORDPRESS网站响应慢的罪魁祸首,你仅仅需要一个优化方案。...
  13. 一个很酷的在线生成漫画头像的网站
  14. IIP3/IMD/IM3/P1dB
  15. 海德汉角度编码器RCN727F与替代型号RCN8390F参数对比
  16. SEOER应当避免赌徒式的外链操作手法
  17. 测量地球半径的古希腊方法
  18. [WP/ctfshow/XXE]ctfshow_XXE_web373-378
  19. USB转多串口产品设计
  20. 代码坏味道与重构之冗赘的元素和夸夸其谈的通用性

热门文章

  1. Android逆向之路---脱壳360加固
  2. leetcode题目解答报告(1)
  3. NGUI 3.5教程(六)Font字体
  4. Software Engineering | Factory method pattern
  5. L4 如何在XCode中下进行工作
  6. ASP.NET常用的26个优化性能方法
  7. Notes-stringr-part2
  8. jenkins安装和使用
  9. Spring HTTP Invoker使用介绍
  10. java基础专栏—CommonApi