带有nginx错误的laravel项目

带有nginx错误的laravel项目,laravel,nginx,Laravel,Nginx,我已将我的laravel项目上传到远程linux主机。该项目在我的本地windows homestead上运行良好。但当我将其放在linux主机上时,它不起作用。 项目根目录是:/var/www/html/blog。nginx配置如下所示: `server { listen 80; #listen [::]:80; server_name www.antichina.us ; index index.html index.h

我已将我的laravel项目上传到远程linux主机。该项目在我的本地windows homestead上运行良好。但当我将其放在linux主机上时,它不起作用。 项目根目录是:/var/www/html/blog。nginx配置如下所示:

`server
    {
        listen 80;
        #listen [::]:80;
        server_name www.antichina.us ;
        index index.html index.htm index.php default.html default.htm default.php;
        root  /var/www/html/blog/public;

       # include other.conf;
        #error_page   404   /404.html;

        # Deny access to PHP files in specific directory
        #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }

        include enable-php.conf;

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }

        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }

        location ~ /.well-known {
            allow all;
        }

        location ~ /\.
        {
            deny all;
        }



        access_log off;
    }
`

当我访问带有域的项目时,(给出一个http 500错误。但是当我在nginx配置文件中将根设置为/var/www/html/blog时,项目的索引页通过visit:工作,其他路由都返回404错误


我已经尝试了我的方法,但似乎没有一个有效。有人能帮我吗?谢谢!

将此添加到您的nginx配置中

location / {
    try_files $uri $uri/ /index.php?$query_string;
}
您的索引行也只需要:

index index.php;
这个文件里有什么

include enable-php.conf;

你的标题说有错误,但你没有说它们是什么。当我访问带有域的项目时,(给出一个http 500错误。但是当我在nginx配置文件中将根设置为/var/www/html/blog时,项目的索引页通过访问工作:,其他路由都返回404错误。在enable-php.conf文件中:
location~[^/]\.php(/|$){try_files$uri=404;fastcgi_pass unix:/tmp/php-cgi.sock;fastcgi_index index.php;include fastcgi.conf;}
你确定你使用的是
fastcgi
而不是
php-fpm
?实际上我对nginx的配置知之甚少。你可以访问linux主机命令行吗?如果可以,请键入
ps aux | grep-php-fpm
。你应该看到类似
1 root-php-fpm主进程的内容。root 962 0.0.4 151436 4892?Ss 15:48 0:00 php fpm:主进程(/usr/local/php/etc/php fpm.conf)www 963 0.0 0.4 151436 4300?S 15:48 0:00 php fpm:pool www 964 0.0 0.4 151436 4296?S 15:48 0:00 php fpm:pool wwwroot 981 0.0 0.0 6380 700 pts/1 S+16:08 0:00 grep php fpm