七叶笔记 » Linux » centos7如何安装php-fpm

centos7如何安装php-fpm

centos7安装“php-fpm”的方法:首先通过yum安装“php-fpm”相关组件;然后在“default.conf”中修改内容用以支持php;最后重启nginx服务即可。

推荐:《centos入门教程

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

环境

[root@localhost html]# cat /etc/centos-releaseCentOS Linux release 7.1.1503 (Core) [root@localhost sbin]# /usr/sbin/nginx -vnginx version: nginx/1.14.0[root@localhost /]# php-fpm -vPHP 5.4.16 (fpm-fcgi) (built: Apr 12 2018 19:03:25)Copyright (c) 1997-2013 The PHP GroupZend 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.rpmyum install -y nginxsystemctl start nginxsystemctl status nginxsystemctl stop nginxsystemctl 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-mcryptsystemctl status php-fpmsystemctl start php-fpmsystemctl 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

<?php    phpinfo();?>

打开:http://192.168.0.61

相关文章