我的操作系统:Ubuntu 12.10 Web服务器环境是: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;
}
}
BTW,此配置为optimized for Yii framework
问题是,当我尝试进入网站时,出现以下错误:
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
- 递归地递归整个父目录,其中网站位于。
我无法弄清楚可能出现什么问题。 PLease帮助我解决这个问题。我可以给任何想要帮助的人提供远程访问。
我刚用path_to_website
替换了真实路径以获得信心。就这样。这是真正的道路
答案 0 :(得分:0)
set $host_path "path_to_website";
您需要定义您的path_to_website是什么:
即:/ var / www /
打开终端
列出项目
答案 1 :(得分:0)
nginx日志文件永远不会存在。如果它说它是“权限被拒绝”错误,那么它就是。你需要
确保用户www-data(根据您的屏幕截图运行nginx的用户)可以读取此文件夹本身“path_to_website”。尝试此操作的一种方法是在终端中运行此命令:
sudo -u www-data ls path_to_website
并查看是否拒绝了www-data或
的权限 ls -la path_to_website
调查该路径的权限信息。