【发布时间】:2016-06-30 10:22:05
【问题描述】:
在使用 nginx 在 Ubuntu 服务器上重新启动基于 laravel 的网站后,并正确配置了所有内容(希望,至少以前可以正常工作),我只能访问索引页面,而不能访问任何其他页面 - nginx 不断抛出 404 不找到了。
认为可能是权限问题,但我已经尝试过
sudo chown -R :www-data /var/www/foo-bar
sudo chmod -R 775 /var/www/foo-bar/storage
sudo chmod -R 775 /var/www/foo-bar/resources
但似乎没有帮助。这是我的 nginx 配置文件:
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /var/www/foo-bar/public;
index index.php index.html index.htm;
server_name 120.25.203.113;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
有什么想法吗? (试试http://120.25.203.113/,如果有兴趣可以点击中心按钮查看!)
更新:错误日志显示
[error] 24119#0: *77 open() "/var/www/ozunimate/public/student/register" failed (2: No such file or directory), client: 14.202.230.9, server: 120.25.203.113, request: "GET /student/register HTTP/1.1", host: "120.25.203.113", referrer: "http://120.25.203.113/"
“student/register”不在/public下,应该重定向(以前在重启之前正常重定向)。似乎重定向不再起作用了。
【问题讨论】:
-
您能否使用您的
/etc/nginx/sites-enabled/default文件的副本更新您的问题(假设您没有创建不同的虚拟主机文件,在这种情况下发布该文件)。 -
当然,已编辑。 @约瑟夫
-
你的配置看起来和我的一样,我的在 Laravel 5 上运行良好。你使用的是 Laravel 5 还是 4?无论如何,我已经赞成你的问题,所以希望其他人会注意到它。
-
我正在使用 Laravel 5。它之前工作过,在重新启动后以某种方式抛出 404 错误。谢谢大家的支持!
-
您编写了命令 'sudo chown -R :www-data /var/www/foo-bar' 但在您的配置中,根目录是 'root /var/www/foo-bar/public; '。公共文件夹的权限是否正确?因为 404 not found 看起来 nginx 找不到所需的路径。你能启用错误日志并检查写入的内容吗?