php - centos7搭建Lnmp环境
本文介绍了php - centos7搭建Lnmp环境的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
各位大神,我搭建完lnmp环境之后,通过ip访问,出现以前问题
下面是我的Nginx配置文件:
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.php index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# 添加下面内容
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
include fastcgi_params;
#include fastcgi.conf;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
我的目录:
[michael@localhost html]$ pwd
/usr/share/nginx/html
[michael@localhost html]$ ll
total 35272
-rw-r--r--. 1 michael www 15086 Jun 26 2016 favicon.ico
-rw-rw-r--. 1 michael michael 7 Jul 31 21:49 index.html
-rw-rw-r--. 1 michael michael 20 Jul 24 04:14 index.php
-rw-r--r--. 1 michael www 432 Aug 5 2016 index.php.bak
-rw-r--r--. 1 michael www 36085974 Feb 20 03:50 iwwenbo.zip
drwxr-xr-x. 3 michael www 52 Aug 17 2016 sites
[michael@localhost html]$ cat index.php
<?php
phpinfo();
?>
请帮我看看问题出在哪里?
解决方案
方式一
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;
#include fastcgi.conf;
}
方式二
server {
root /usr/share/nginx/html;#sever中增加这段
}
这篇关于php - centos7搭建Lnmp环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文