【问题标题】:Page is not working in cpanel using Laravel 5.6页面在使用 Laravel 5.6 的 cpanel 中不起作用
【发布时间】:2020-07-15 08:06:54
【问题描述】:

我在本地机器上创建了 Laravel 项目,并且还创建了数据库。在本地机器上,一个项目运行没有任何问题,但是我将项目文件上传到了 public_html 文件夹内的分片服务器 Cpanel 中,我访问了它说的 URL 此页面不工作HTTP 错误 500

Cpanel PHP 版本为 7.0 Laravel 版本是 5.6

但我将公用文件夹中的内容文件移动到根文件夹(public_html),并更改了 index.php 文件中的路径

require __DIR__.'/vendor/autoload.php';
$app = require_once __DIR__.'/bootstrap/app.php';

还有 server.php 文件我也改成这样的路径。

if ($uri !== '/' && file_exists(__DIR__.'/public_html'.$uri)) {
    return false;
}

require_once __DIR__.'/public_html/index.php';

还有我的 htaccess

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

    RewriteEngine On

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

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

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

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “alt-php70” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-alt-php70 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit

请帮助解决此问题。

【问题讨论】:

    标签: php laravel laravel-5


    【解决方案1】:

    您应该将所有 public 文件夹 文件放在 public_html 文件夹中,并将其余项目文件放在另一个文件夹中,您可以将其命名为 laravel。然后你应该像这样改变你的 index.php 文件:

    require __DIR__.'/../laravel/vendor/autoload.php';
    $app = require_once __DIR__.'/../laravel/bootstrap/app.php';
    

    【讨论】:

    • 非常感谢并修复了这个问题,我使用 alt-php 7.0 的 Cpanel 并更改为 7.1 它正在工作
    猜你喜欢
    • 2018-09-28
    • 2020-05-03
    • 1970-01-01
    • 2018-07-30
    • 1970-01-01
    • 2018-08-01
    • 2018-09-28
    • 2020-11-05
    • 1970-01-01
    相关资源
    最近更新 更多