Laravel 5.2和PHP 7的Nginx配置:路由不工作

Laravel 5.2和PHP 7的Nginx配置:路由不工作,php,laravel,nginx,laravel-5.2,php-7,Php,Laravel,Nginx,Laravel 5.2,Php 7,我正在尝试设置一个AWS Ubuntu服务器来托管一个Laravel项目。我在让路由正常工作方面遇到了问题,我怀疑我的Nginx虚拟主机配置文件是罪魁祸首 我特别认为try_files行是问题所在?我尝试了try_files$uri$uri//index.php$is_args$args以及try_文件$uri$uri//index.php?$query_字符串,以及其他一些错误结果,包括: 404错误 500个错误 链接到源代码的下载 它的当前行为被重定向到/index.php/(显示Lar

我正在尝试设置一个AWS Ubuntu服务器来托管一个Laravel项目。我在让路由正常工作方面遇到了问题,我怀疑我的Nginx虚拟主机配置文件是罪魁祸首

我特别认为try_files行是问题所在?我尝试了
try_files$uri$uri//index.php$is_args$args
以及
try_文件$uri$uri//index.php?$query_字符串,以及其他一些错误结果,包括:

  • 404错误
  • 500个错误
  • 链接到源代码的下载
  • 它的当前行为被重定向到/index.php/(显示Laravel欢迎页面)
这里是my/etc/nginx/sites enabled/default:

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

    root /var/www/html/public;
    index index.php index.html index.htm;

    # Make site accessible from amazon aws
    server_name xxxx.us-west-2.compute.amazonaws.com;

    location / {
            # Try file, then try folder, then pass to Laravel's /public/index.php
            try_files $uri $uri/ /index.php$is_args$args;
    }

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    location ~ \.php$ {
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini

            try_files $uri /index.php =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
            fastcgi_index index.php;
            include fastcgi_params;
    }
}
这是文件的当前状态,正如我所说,它当前将所有实际路由重定向到
blahblah.com/index.php/
,并显示Laravel欢迎页面。未设置的假路由会导致出现Laravel 404页面

我被难住了,因为有好几本指南,我已经尝试了所有我能找到的建议,所以我一定错过了什么

看来php7工作正常,不是问题所在,或者这可能是php配置文件中的问题

发展情况:
如果我使用其IP访问该网站(感谢Oliver Queen),它似乎可以正常工作,你知道我如何在使用域名时使其工作吗?

用以下代码替换你当前的
位置/

location / {
    try_files $uri $uri/ /index.php?$query_string;
}
然后将其下方的位置替换为:

location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
}

用以下代码替换当前的
位置/

location / {
    try_files $uri $uri/ /index.php?$query_string;
}
然后将其下方的位置替换为:

location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
}

就像我说的,我已经试过了。不过我会逗你开心的。更改了文件,
sudo service nginx restart
,重新加载页面,行为没有任何更改。抱歉@aurath,我提前提交了。请再次尝试上面的回复谢谢。试过之后,这种行为依然存在。每个有效的路由都被重定向到
blahblah.com/index.php/
,并显示欢迎页面。无效路由获取Laravel的404页面。如果直接访问IP会发生什么?正如我所说,已经尝试过该选项。不过我会逗你开心的。更改了文件,
sudo service nginx restart
,重新加载页面,行为没有任何更改。抱歉@aurath,我提前提交了。请再次尝试上面的回复谢谢。试过之后,这种行为依然存在。每个有效的路由都被重定向到
blahblah.com/index.php/
,并显示欢迎页面。获取Laravel 404页面的路由无效。如果直接访问IP会发生什么情况?我猜域名不可能实现。我猜域名不可能实现。