不了解的话问系列:PHP网站上使用nginx遇到的一些问题
准备用php做网站,域名是dev.hellotools.org,根目录下有四个文件,分别是,
Index.php,这是主页
About.php,关于这一页
404.php,404页
A和B是目录,这意味着根目录下有一个二级目录,里面有一个page.php
现在我想实现以下功能,
游览dev.hellotools.org时,浏览器上的地址栏显示dev.hellotools.org,浏览器显示index.php的内容;
访问dev.hellotools.org/about时,浏览器的地址栏显示dev.hellotools.org/about浏览器显示about.php的内容;
访问dev.hellotools.org/nono时,浏览器的地址栏显示dev.hellotools.org/nono浏览器显示404.php的内容;
访问dev.hellotools.org/a/b/page时,浏览器的地址栏显示dev.hellotools.org/a/b/page浏览器显示
所以我的nginx配置如下。
服务器
{
听80;
服务器名dev.hellotools.org;
index.htmlindex.htmindex.phpdefault.htmldefault.htmdefault.php指数;
root/home/www root/dev . hello tools . org;
charset utf-8;
error _ page 404/404 . PHP;
##启用php路径信息
地点~ [^/]\.php(/|$)
{
fastcgi _ pass UNIX :/tmp/PHP-CGI . sock;
index.php指数;
包括fastcgi.conf
include pathinfo.conf
{}
位置/
try _ files $ uri $ uri . PHP/index . PHP;
{}
{}
我想不出我的配置有什么问题。我访问关于页面的时候,文件是直接下载的,404出不去。不知道哪里出了问题。
每页内容写的很清楚,就几个简单的汉字和字母。例如,如果你打开index.php,页面的内容是:index.php.其他一切都相似。
折腾了一晚上,还是没找到。希望认识我的大哥给点意见。