几乎每个页面都出现"page not found"错误。我搜索了谷歌,有人建议nginx的URL_rewrite可能有问题。
我已经这样改变了nginx/conf/nginx.config.default
location / {
root html;
index index.html index.htm;
try_files $uri $uri/ /index.php?$args;
}
但是它仍然不能工作。
服务器系统:Centos 7nginx: 1.4.4PHP版本:5.5.7
您需要做的第一件事是在文档根目录下创建两个文件。
第一个调用test.html,并在文件中写入以下内容:
然后创建一个名为test.php的文件,其中包含以下内容:这是一个测试
<?php
// Show all information, defaults to INFO_ALL
phpinfo();
?>
浏览到你的浏览器,像
http://example.com/test.html和http://example.com/test.php
我猜html会加载,而php不会。
这是由于php和nginx没有正确的文件权限。
首先要做的是执行以下命令:
chown -R nginx:nginx documentroot
并继续执行该命令,每次添加/*,直到出现错误。
在你的nginx.conf文件中,你需要确保你有以下内容:
location ~ '.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
然后进入/etc/php- fmp .d/www.conf
并确保以下内容设置为:
listen.owner = nginx
listen.group = nginx
我已经修改了nginx/conf/nginx.config.default
似乎文件是原始配置文件,而不是工作的文件,试着找到无.default
扩展名的nginx.config
文件。
如果没有找到,请尝试将默认值复制到名称为nginx.config