【问题标题】:Laravel 5.8 Fresh Deployment Not Working In Hostinger Shared HostingLaravel 5.8 全新部署在 Hostinger 共享主机中不起作用
【发布时间】:2020-02-20 17:42:39
【问题描述】:

我尝试部署一个全新的 laravel 应用程序。我安装了一个 laravel 5.8 并上传到 github 存储库。

自从我尝试运行 php artisan serve 后,存储库或项目文件夹正在工作,它成功显示了 laravel 主屏幕页面。

我尝试使用 ssh 连接到我的共享主机。

这是我已经完成的步骤:

  1. 通过 ssh 访问
  2. 创建一个项目文件夹mkdir my-assignment-calculator 然后 cd my-assignment-calculator
  3. 克隆项目存储库。 git clone **repo_url**
  4. 浏览项目文件夹,cd my-assignment-calculator
  5. 复制 .env 文件,cp .env-example .env
  6. 安装作曲家包。 composer install
  7. 然后将Public文件夹中的所有文件复制到public_html文件夹中
  8. 转到 public_html 然后更新 index.php,nano index.php
  9. 在 index.php 中,我更新了这两行,vendor/autoload.php 和 bootstrap/app.php

这是#9 的示例代码:

require __DIR__.'/../my-assignment-calculator/my-assignment-calculator/vendor/autoload.php';

/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/

$app = require_once 
__DIR__.'/../my-assignment-calculator/my-assignment-calculator/bootstrap/app.php';

这是我的项目文件夹的结构

-public_html
-domains
    --my_assignment_calculator
    --my_assignment_calculator
        ---laravel files

当前输出只是白屏。我尝试检查开发人员工具或开发工具,没有错误。它只是一个白色的背景。和以前一样。

我试图检查 .htaccess 文件,但我没有碰过这个文件。这是.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>

那么预期的输出是什么

应该显示 laravel 欢迎或主屏幕页面

【问题讨论】:

  • 尝试替换“DIR”。使用完整路径,我注意到“DIR”。不适用于某些服务器。

标签: php laravel laravel-5 deployment web-hosting


【解决方案1】:

laravel 文件夹位于根目录中,然后您的所有公用文件夹文件将其传输到 public_html 然后通过添加 laravel 目录转到您的 public_html 配置中的索引文件,如下所示:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-06-28
    • 2019-09-25
    • 1970-01-01
    • 2018-06-07
    • 2018-12-02
    • 1970-01-01
    • 2015-06-06
    相关资源
    最近更新 更多