centos7 安装 php-fpm_CentOS7用yum方式安装Nginx+php-fpm

title: CentOS7用yum方式安装Nginx+php-fpm

categories: Linux

tags:

- Nginx

- PHP

timezone: Asia/Shanghai

date: 2019-01-09

环境

[root@localhost html]# cat /etc/centos-release

CentOS Linux release 7.1.1503 (Core)

[root@localhost sbin]# /usr/sbin/nginx -v

nginx version: nginx/1.14.0

[root@localhost /]# php-fpm -v

PHP 5.4.16 (fpm-fcgi) (built: Apr 12 2018 19:03:25)

Copyright (c) 1997-2013 The PHP Group

Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

1.安装nginx

rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

yum install -y nginx

systemctl start nginx

systemctl status nginx

systemctl stop nginx

systemctl enable nginx

用浏览器打开以下地址能访问就说明配置成功了

http://192.168.0.61/

2.yum安装php-fpm相关组件

yum -y install php php-fpm php-gd php-mysql php-common php-pear php-mbstring php-mcrypt

systemctl status php-fpm

systemctl start php-fpm

systemctl enable php-fpm

3.编辑/etc/nginx/conf.d/default.conf并添加以下内容以支持php

vim /etc/nginx/conf.d/default.conf

#

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;

}

修改完配置以后需要重启nginx服务

4.建立index.php文件并测试

vim /usr/share/nginx/html/index.php

phpinfo();

?>

打开:http://192.168.0.61

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值