Cpanel 共享主机中的 Laravel 5.5 错误 500

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/47784923/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 17:05:53  来源:igfitidea点击:

Laravel 5.5 Error 500 in Cpanel Shared Hosting

phplaravelcpanellaravel-5.5http-status-code-500

提问by Arie Sastra

I already upload my laravel project folder into cpanel hosting. I did't have VPS. I has read many example in laracast and stackoveflow, but still get this 500 internal error. This is my setting.

我已经将我的 Laravel 项目文件夹上传到 cpanel 托管。我没有VPS。我已经阅读了 laracast 和 stackoveflow 中的许多示例,但仍然收到此 500 内部错误。这是我的设置。

I has separated public folder in my laravel project and put the other in root directory of my hosting like this.

我已经在我的 Laravel 项目中分离了公共文件夹,并将另一个放在我的主机的根目录中。

|-- my_other_folder_project/
|-- [some other folders...]
|-- public_html/ 
|   |-- [some other folders...]
|   |-- my_public_project/

And Change index.php setting into :

并将 index.php 设置更改为:

from

require __DIR__.'/../vendor/autoload.php';

to

require __DIR__.'/../../my_other_folder_project/vendor/autoload.php';

And From

并且从

$app = require_once __DIR__.'/../bootstrap/app.php';

to

$app = require_once __DIR__.'/../../my_other_folder_project/bootstrap/app.php';

I has create .htaccess file for public folder like this :

我已经为公共文件夹创建了 .htaccess 文件,如下所示:

DirectoryIndex index.php

<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]

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>

My PHP for this is 7.1 and I've checked other requirenment like OpenSSL, PDO, Mbstring, Tokenizer Already installed.

我的 PHP 是 7.1,我已经检查了其他要求,如 OpenSSL、PDO、Mbstring、Tokenizer 已经安装。

But Still get this 500 internal server error, I've searching many refference for this but pointed to the step I've already do.

但是仍然得到这个 500 内部服务器错误,我为此搜索了很多参考,但指出了我已经做过的步骤。

回答by Skyvory

Error 500 could appear from having server's PHP version lower than minimum version requirement by Laravel.

错误 500 可能是因为服务器的 PHP 版本低于 Laravel 的最低版本要求。

From my experience, the problem came out when I'm using Laravel 5.6 when my PHP version was still at 7.0 while it actually requires at least PHP 7.1.3. Changing my PHP version at PHP Selector in cPanel solved the issue.

根据我的经验,当我使用 Laravel 5.6 时出现问题,而我的 PHP 版本仍为 7.0,而实际上它至少需要 PHP 7.1.3。在 cPanel 中的 PHP Selector 更改我的 PHP 版本解决了这个问题。

Make sure your server's PHP version is equal or higher than what your Laravel version needs.

确保您的服务器的 PHP 版本等于或高于您的 Laravel 版本所需的版本。

回答by Ramadhan

First time, you can check your php info

第一次,你可以检查你的php信息

<?php
phpinfo();
?>

and you can search "mbstring" in there...

你可以在那里搜索“mbstring”......

mbstring

字符串

if mbstring still not installed, you can ask the provider to installed that.

如果 mbstring 仍未安装,您可以要求提供商安装它。

if already installed and still got the error 500, better you must check your php version in phpinfo(). And clear your cache with php artisan command. when you have a permission to shell, you can try to check your php version with command "php -v" and see the default php with which php.

如果已经安装但仍然出现错误 500,最好您必须在 phpinfo() 中检查您的 php 版本。并使用 php artisan 命令清除缓存。当您有shell权限时,您可以尝试使用命令“php -v”检查您的php版本,并查看默认的php with which php.ini

回答by bubune_caleb

Just to bring to light on some issues I faced with my upload on a shared hosting and how I saved it. The error 500 appeared my page.

只是为了揭示我在共享主机上上传时遇到的一些问题以及我如何保存它。错误 500 出现在我的页面。

After several investigation, I discovered that the hidden files both in the public folder and the main app were not included in my uploads.

经过多次调查,我发现公共文件夹和主应用程序中的隐藏文件都没有包含在我的上传中。

So just make sure you show hidden filesbefore archiving/uploading

因此,请确保在存档/上传之前显示隐藏文件

As it will not get uploaded/archived if not enabled to show hidden files.

因为如果未启用显示隐藏文件,它将不会被上传/存档。

The absence of these files too generate the 500 error.

缺少这些文件也会产生 500 错误。

I worked with laravel 5.5.*

我使用 laravel 5.5.*

回答by Ritesh

None of the above solutions worked for me.. so tried :

以上解决方案都不适合我..所以尝试过:

php composer.phar install

on my shared hosting after uploading (for the first time) my project build on my local machine and it worked.

上传(第一次)后在我的共享主机上,我的项目在我的本地机器上构建并且它工作正常。

回答by SUHAIL KC

Make sure you had run composer installand should have a .env file

确保你已经运行composer install并且应该有一个 .env 文件