配置lnmp时出现“file not found?

问题:

  昨天测试并搭建lnmp架构,在测试过程中,挂载好测试环境时在浏览器上测试网站出现“file not found",使用命令curl时也出现”file not found",

解答:

  查看百度时,很多方法指向添加fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;但是测试中不行,没有效果;

分析:

  查看原理并了解php运行过程,确实网站的fastcgi找不到php文件,但是我这边配置好了php文件加载,配置如下:

http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 81;
server_name blog.etiantian.org;
location / {
root html/blog;
index index.php index.html index.htm;
}
location ~*.*\.(php|php5)?$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
}
}

但是运行并测试时就提示找不到file not found,怎么办?

解决方法:

       为了正常显示php时,就要让他找到php网站目录,只要在

location ~*.*\.(php|php5)?$ {

root   html/blog;    #网站目录,增加这一行;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}

重启nginx,php服务后就可以显示网站,如下 :

命令行:curl blog.etiantian.org:81/1.php

浏览器:

恢复正常了。

猜你喜欢

转载自www.cnblogs.com/wang50902/p/10842349.html