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-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
<?php phpinfo(); ?>
打开:http://192.168.0.61
以上就是centos7如何安装php-fpm的详细内容,更多请关注其它相关文章!