我的操作系统:Ubuntu 12.10Web服务器环境为:Nginx+PHP-FPM
根据本教程安装
以下是网站的nginx conf文件
server {
set $host_path "path_to_website";
server_name website.local;
root $host_path;
set $yii_bootstrap "index.php";
charset utf-8;
index index.php index.html;
log_not_found off;
location / {
index index.html $yii_bootstrap;
try_files $uri $uri/ /$yii_bootstrap?$args;
}
location ~ ^/(protected|framework|themes/'w+/views) {
deny all;
}
#avoid processing of calls to unexisting static files by yii
location ~ '.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
try_files $uri =404;
}
location ~ '.php$ {
fastcgi_split_path_info ^(.+'.php)(.*)$;
#let yii catch the calls to unexising PHP files
set $fsn /$yii_bootstrap;
if (-f $document_root$fastcgi_script_name){
set $fsn $fastcgi_script_name;
}
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /'.ht {
deny all;
}
}
顺便说一句,此配置针对Yii框架进行了优化
问题是,当我试图进入网站时,得到以下错误:
File not found.
当我打开nginx error.log
文件时,我看到以下内容
2013/03/22 23:36:45 [crit] 14388#0: *4 stat() "path_to_website" failed (13: Permission denied), client: 127.0.0.1, server: website.local, request: "GET / HTTP/1.1", host: "website.local"
2013/03/22 23:36:45 [crit] 14388#0: *4 stat() "path_to_website" failed (13: Permission denied), client: 127.0.0.1, server: website.local, request: "GET / HTTP/1.1", host: "website.local"
2013/03/22 23:36:45 [crit] 14388#0: *4 stat() "path_to_websiteindex.php" failed (13: Permission denied), client: 127.0.0.1, server: website.local, request: "GET / HTTP/1.1", host: "website.local"
2013/03/22 23:36:45 [error] 14388#0: *4 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 127.0.0.1, server: website.local, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "website.local"
我对网站的路径有100%的把握,也添加到了主机文件website.local
中。也递归地chown
遍历整个父目录,网站所在的位置。
我想不出有什么问题。请帮我解决这个问题。我可以给任何想帮忙的人远程访问。
注释
我只是用这个path_to_website
替换了真实的路径,以增强信心。仅此而已。这是真实路径
set $host_path "path_to_website";
您需要定义您的path_to_website是什么:
即:/var/www/
开放式终端
列表项
- cd到www目录的根目录中
- 键入"pwd",无论结果如何
- 将其输入$host_path
nginx日志文件从不说谎。如果它说这是一个"拒绝权限"错误,那么它就是。你需要
-
确保这个文件夹本身"path_towebsite"对于用户www数据是可读的(这是基于屏幕截图运行nginx的用户(。一种尝试的方法是在终端中运行此命令:
sudo -u www-data ls path_to_website
查看是否拒绝www数据或仅拒绝
ls -la path_to_website
以调查该路径的权限信息。
- 用户www数据可能无法访问"path_to_website"的父文件夹。例如,如果您的path_to_website是"/var/www/mysite/",那么www数据可能无法读取"/var/"或"/var/www">