LNMP搭建(yum)

CentOS官方镜像不提供nginx,
http://nginx.org
http://nginx.org/en/linux_packages.html#stable

yum install nginx
yum  -y install php php-fpm
/etc/nginx/                         #配置文件目录
 /etc/nginx/conf.d/default.conf      #配置文件
 /etc/nginx/fastcgi_params           #fast-cgi
 /etc/nginx/nginx.conf               #主配置文件
 /etc/nginx/scgi_params
 /usr/share/nginx/html/index.html    #默认首页
[root@localhost ~]# cat /etc/nginx/fastcgi_params
.....
 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;  //新添加
.....
[root@localhost ~]# vim /etc/nginx/conf.d/default.conf
......
location / {
 root /usr/share/nginx/html;
 index index.html index.htm index.php;
 }
......
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;
 }
.......
service php-fpm restart
service nginx restart
[root@localhost ~]# chkconfig --level 345 php-fpm on
[root@localhost ~]# chkconfig --level 345 nginx on
root@localhost ~]# cat /usr/share/nginx/html/index.php
<?php
phpinfo(); 
?>
公众号请关注:侠之大者
原文地址:https://www.cnblogs.com/kamil/p/5163182.html