laravel在站点的二级目录下,访问报500错误

最近刚接触laravel,项目放在了网站的二级目录,配置了二级域名,访问时报500错误。当项目放在网站根目录时,用一级域名可以正常访问。
ngix配置文件:chat.abc.cc.conf 如下

server {
        listen       80;
        root /www/web/abc/public_html/chat;
        server_name chat.abc.cc;
        index  index.html index.php index.htm;
        error_page  400 /errpage/400.html;
        error_page  403 /errpage/403.html;
        error_page  404 /errpage/404.html;
        error_page  405 /errpage/405.html;
        error_page  503 /errpage/503.html;
        location ~ \.php$ {
                proxy_pass http://127.0.0.1:88;
                include naproxy.conf;
        }
        location ~ /\.ht {
                deny  all;
        }
        location / {
                try_files $uri @apache;
        }
        location @apache {
                 internal;
                 proxy_pass http://127.0.0.1:88;
                 include naproxy.conf;
        }
}
阅读 4.6k
3 个回答

500是内部服务错误,请看看你的配置有没有正确,也可看下日志文件

要把laravel的请求重定向到public/index.php里的
try_files $uri $uri/ /index.php$is_args$query_string;
root指向的也应该是public目录

贴上我的简单配置吧,指向public目录

server {
    listen 80;

    root /var/www/html/server/public;

    index index.php index.html;

    server_name coco.dev;

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

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
    #
    #    # With php-fpm (or other unix sockets):
        fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
    #    # With php-cgi (or other tcp sockets):
    #    fastcgi_pass 127.0.0.1:9000;
    }

}
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题