Laravel,部署到 LIFE 服务器后发生未知错误,500 内部服务器错误

Laravel, unknown error after deploy to LIFE server, 500 Internal Server Error

我刚从我的本地服务器部署了一个 laravel 8 项目到 LIFE 服务器,显然一切正常,我设法 运行 composer 成功 (composer update),composer 没有不要抛出任何错误消息,LIFE 服务器的域与文件夹 /project/public 相关联。我也成功地 运行 php artisan migrate,我可以在数据库中看到 artisan 创建的表,因此应用程序已正确连接到数据库。

我也把主工程文件夹的权限改成了755,storage文件夹的权限改成了777。

sudo chmod -R 777 ./storage
sudo chmod -R 777 ./bootstrap/cache/
sudo chmod -R 664 /mainprojectfolder

我用artisan成功生成了新的KEY,用artisan成功清除了缓存。。。也就是说网上找的所有教程都看完了,但是问题还是没有解决。

php artisan key:generate

我还按照官方文档的建议清除了项目缓存:

php artisan config:cache
php artisan route:cache
php artisan view:cache

我还创建了 .htaccess 文件:

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ / [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

当我浏览服务器 URL 时,我看到浏览器正确重定向到 domain/login,这是正确的,只要我没有登录,应用程序就会重定向到登录页面.然后浏览器显示经典的:500 Internal Server Error - The server encountered an internal error or misconfiguration and was unable to complete your request...

不幸的是,我无法访问服务器日志,因为服务器是共享虚拟服务器,所以我无法弄清楚到底是什么问题。

各位大侠能给点建议吗?

经过多次尝试终于找到了解决方法,.htaccess文件错误,我换了:

RewriteRule ^ index.php [L]

与:

RewriteRule ^ /index.php [L]

我在index.php之前添加了/。这已解决问题。