Nginx上的Laravel 4.2获得404(VPS)

Nginx上的Laravel 4.2获得404(VPS),laravel,nginx,vps,Laravel,Nginx,Vps,我正在尝试在nginx上使用laravel4.2。我有一个VPS(Dreamhost),我将Laravel框架放在用户的根路径中(/home/vi360/),公共路径位于/home/vi360/vide360.com.br 我一直在研究几种为Laravel设置nginx的方法,但没有取得任何成功。只有主页(www.vide360.com.br)正在打开,但所有其他页面(由/home/vi360/app/routes.php指导)返回时出现错误404 我创建了/home/vi360/nginx/v

我正在尝试在nginx上使用laravel4.2。我有一个VPS(Dreamhost),我将Laravel框架放在用户的根路径中(
/home/vi360/
),公共路径位于
/home/vi360/vide360.com.br

我一直在研究几种为Laravel设置nginx的方法,但没有取得任何成功。只有主页(www.vide360.com.br)正在打开,但所有其他页面(由
/home/vi360/app/routes.php
指导)返回时出现错误404

我创建了
/home/vi360/nginx/vide360.com.br/vide360.conf
,如下所示:

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    root /home/vi360/vide360.com.br;
    index index.php index.html index.htm;

    server_name [server ip address];

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        try_files $uri =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;
    }
}

我可能做错了什么?

我猜你更改了公用文件夹的名称

Laravel在
public
文件夹中查找其文件。假设您的laravel应用程序运行在
/home/vi360
上,则您的公用文件夹路径将是
/home/vi360/public

那么在你的nginx上,应该是

root /home/vi360/public;
尝试将
vide360.com.br
文件夹重命名回
public
即可。这是因为框架通过启动并将其转发到
public/index.php
文件来跟踪请求

不要忘记在设置更改后重新启动nginx和php fpm

编辑

如果开发人员希望将laravel的公共目录从
public
文件夹更改为其他文件夹,请说
vide360.com.br
,然后编辑位于
App\Providers\AppServiceProvider.php
应用程序服务提供商(ASP)
。然后在
register
方法下,使用您的
新公用文件夹名称添加代码

 $this->app->bind('path.public', function() {
        return base_path().'/vide360.com.br';
    });

谢谢你的回复!我已经更改了“/home/vi360/boostrap/path.php”,将公用文件夹识别为“vide360.com.br”(这是服务器公用文件夹的默认路径)。顺便说一句,如果索引页正在打开,framworking启动得很好,对吗?@DanielGroppo代码根据您的场景进行了更新。您必须将新位置绑定到应用程序,以便代码能够检测到它。更改引导路径只会将请求发送到新文件夹,而不会发送应用程序以检测新位置。