环境

1, CentOS 7
2, nginx1.12.2
3, php7.0
nginx已经安装完成,且document root 目录为/usr/share/nginx/html。

步骤

1,添加php7.0源

rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

2,查看php7.0源

yum info php70w

3,安装php7.0

yum install php70w php70w-fpm

4,查看php版本

php -v

5,接下来配置/etc/php-fpm.d/www.conf,将user和group改为nginx。

vi /etc/php-fpm.d/www.conf
----------------------------------
user = nginx
group = nginx

6,启动php-fpm服务

/usr/sbin/php-fpm

7,检查php-fpm服务

ps -ef | grep php-fpm
netstat -tlnp | grep 9000

8,修改nginx配置,使nginx能够将php脚本的处理转给php-fpm模块。

vi /etc/nginx/conf.d/default.conf(使用yum安装的nginx 1.12.2 80端口对应的配置文件位置。
默认是注释掉的,取消注释即可。如果没有,则添加。注意将/script改为$document_root)
-----------------------------
    location ~ \.php$ {        root           /usr/share/nginx/html;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

root的值需要修改为/usr/share/nginx/html。
fastcgi_param的值需要修改为$document_root$fastcgi_script_name;。

9,nginx重载配置

nginx -s reload

实际情况中,如重载nginx配置与此处给出的方式不同,自动替换成其它方式即可。

10,编辑一个测试的php程序。

vi /usr/share/nginx/html/index.php (/usr/share/nginx/html是document_root目录)
-------------------------------------
<?php
    phpinfo();
?>

11,输入index.php页面的输出结果

http://192.168.253.130/index.php

12,设置session目录访问权限

cd /var/lib/php
chown -R nginx:nginx *

务必保证php-fpm的启动账户(本文设置的启动账户为nginx)对存放session的目录具有读写权限,否则将不能正确使用session。

其它

查看可以安装的php插件:yum list php70w*

启动php-fpm:systemctl start php-fpm 或 /usr/sbin/php-fpm
停止php-fpm:systemctl stop php-fpm
重启php-fpm:systemctl restart php-fpm

php-fpm配置文件:/etc/php-fpm.conf /etc/php-fpm.d/*.conf

Linux 利用yum源安装php7.0+nginx相关推荐

  1. Linux 利用yum源安装php5.6+nginx

    前言 CentOS 7 nginx1.12.2 php5.6 nginx已经安装完成,且document root 目录为/usr/share/nginx/html. 步骤 1,添加php5.6源 s ...

  2. Linux 利用yum源安装nginx

    环境 1, CentOS 7 2, nginx 1.12.2 步骤 1,添加nginx源 rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS ...

  3. Linux 利用yum源安装subversion(svn)客户端

    前言 CentOS 7 subversion(svn) 安装过程 yum 方式安装 shell> yum install subversion 检查是否安装成功 shell> svn -- ...

  4. linux 利用yum源安装mysql5.7

    前言 CentOS 7 MySQL 5.7 查找mysql源 http://repo.mysql.com 步骤 添加mysql源 shell> rpm -ivh http://repo.mysq ...

  5. Linux 通过yum源安装subversion(svn)服务端

    目录 前言 通过yum源安装subversion(svn)服务端 基本的SVN服务端配操作 确定一个SVN目录 新建SVN仓库 给SVN仓库添加用户 给SVN仓库的用户授权 SVN仓库配置 启动服务器 ...

  6. Centos 利用yum源安装 nginx stream模块

    环境 CentOS 7.9 (腾讯云服务器) nginx 1.20.1 配置stream参考这里. nginx 动态模块 nginx 1.9.11 开始增加加载动态模块支持,从此不再需要替换nginx ...

  7. yum 源没有php7.0,yum安装最新版php7的操作方法

    yum安装最新版php7的操作方法 发布时间:2021-01-12 10:28:17 来源:亿速云 阅读:96 作者:栢白 这篇文章主要介绍了yum安装最新版php7的操作方法,具有一定借鉴价值,需要 ...

  8. CentOS 8 利用yum源安装nginx

    环境 1, CentOS 8 2, nginx 1.18.0 步骤 1,先安装 yum-utils shell> yum install yum-utils 2,添加nginx源.创建文件/et ...

  9. Centos 利用yum源安装 nginx 1.20.1

    环境 CentOS 7.9 (腾讯云服务器) nginx 1.20.1 yum源说明 腾讯云的 CentOS 服务器,用的是腾讯的yum源镜像. 感兴趣的可以去/etc/yum.repos.d中看看. ...

最新文章

  1. 解决ModuleNotFoundError: No module named ‘numpy.core._multiarray_umath‘ 错误
  2. 怎么排号_春节将至,那些过年不回家的人们都是怎么过年的?
  3. vue获取当前日期和时间并进行格式化
  4. Eclipse启动时布局不合理调整
  5. jeecg输入中文查询导表为空_简单查询
  6. stm32 Flash读写[库函数]
  7. 真心话大冒险C++版本
  8. 【优化算法】人工生态系统优化算法(AEO)【含Matlab源码 023期】
  9. 国产芯片WiFi物联网智能插座—电源功能设计
  10. SAP FICO 第三节 BDC和LTMC导入S4财务科目
  11. C++计算两平面之间的夹角
  12. itest(爱测试) 4.3.1 发布,开源BUG 跟踪管理 amp; 敏捷测试管理软件
  13. ProSpec 胶质源性神经营养因子人重组说明书
  14. 通过手机使用广域网访问局域网的服务器
  15. 计算机学院考研动员大会,计算机学院2018年考研动员大会顺利召开
  16. 雷电9模拟器安装抓包工具whistle证书
  17. jquery使用html()css不生效,jquery可以添加css样式吗?
  18. 简易集成的MVP模块化App框架(1/3)
  19. vue-cli脚手架build目录下utils.js工具配置文件
  20. Matlab 伪彩色处理方法总结(密度分割法、灰度级变换法、频域变换法)

热门文章

  1. Spring AOP之四:利用AOP实现动态数据源切换
  2. getContextPath、getServletPath、getRequestURI的区别
  3. 酷我音乐盒里的MV怎么下载
  4. Spring Bean引用例子
  5. 温故而知新:HttpApplication,HttpModule,HttpContext及Asp.Net页生命周期
  6. idea如何设置自动换行
  7. django写原生sql语句
  8. python3.7.4安装(Windows10)
  9. 支付宝 网页授权 获取用户信息
  10. PHP实现多线程抓取网页