【问题标题】:Uploading Laravel from my localhost to godaddy server将 Laravel 从我的本地主机上传到 Godaddy 服务器
【发布时间】:2018-09-24 06:52:16
【问题描述】:

我在 localhost 中的设置运行良好。我想将我的 Laravel 应用程序上传到我的 GoDaddy 服务器。我创建了一个 FTP 来将我的 Laravel 应用程序传输到我的 GoDaddy 服务器。正如我在创建 FTP 帐户时注意到的那样,文件位于 /webroot 内,所以我在 testapp 内创建了一个 /webroot/testapp 是我的 Laravel 应用程序。在 Laravel 应用程序中,有一个公用文件夹。正如我在谷歌中研究的那样,只有公用文件夹必须在 /public_html 内,而 Laravel 应用程序将在外面。就我而言,它是/webroot。现在将我的 Laravel 应用程序传输到我的服务器后,我没有分离我的公用文件夹。我也将它放在testapp 文件夹中,因为当我将公用文件夹放在我的testapp 文件夹之外并编辑 index.php 文件时,我的主站点位于 WordPress 中,它会导致错误。所以我将公用文件夹添加到我的testapp 文件夹中。当我尝试在浏览器中运行时,它显示 404 (Page Not Found) Error` 所以我尝试在下面编辑我的 index.php 文件

<?php

/**
 * Laravel - A PHP Framework For Web Artisans
 *
 * @package  Laravel
 * @author   Taylor Otwell <taylor@laravel.com>
 */

/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| our application. We just need to utilize it! We'll simply require it
| into the script here so that we don't have to worry about manual
| loading any of our classes later on. It feels great to relax.
|
*/

require __DIR__.'/../testapp/public/bootstrap/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__.'/../testapp/public/bootstrap/app.php';

/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request
| through the kernel, and send the associated response back to
| the client's browser allowing them to enjoy the creative
| and wonderful application we have prepared for them.
|
*/

$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);

$response = $kernel->handle(
    $request = Illuminate\Http\Request::capture()
);

$response->send();

$kernel->terminate($request, $response);

现在有人可以帮我解决这个问题吗?我已经看到其他教程运行良好,但我的不是。非常感谢任何帮助。 TIA

【问题讨论】:

  • 你试过yourwebsite.com/public ..检查它是否工作然后我会给你htaccess代码使它成为root
  • 我试过你的答案,但它会重定向到我的主站点
  • 如果对你有帮助,请看我的回答

标签: php laravel


【解决方案1】:

您应该将整个项目从 localhost 上传到 godaddy,然后要求支持团队编辑指向公共文件夹的主机。

这是一项共享托管服务,因此您无法单独完成。问一下。

【讨论】:

  • 所以你的意思是我会向godaddy寻求帮助?
  • 是的,当我遇到同样的问题时,我要求他们将虚拟主机指向公共文件夹中。只有支持人员无法在共享主机中执行此操作。
  • 但没有向 Godaddy 寻求帮助?这可能吗?
  • 我认为不是。
  • 嗨,我已经解决了!我刚刚在我的主机中升级了我的 php 版本
【解决方案2】:

在根目录下创建 .htaccess 并添加以下代码:-

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule    ^$    public/    [L]
RewriteRule    (.*) public/$1    [L]
</IfModule>

希望对你有帮助!

【讨论】:

  • 我试过你的回答 404 页面错误不再存在,现在它指向我的主要托管站点
  • 你的意思是我将在我的 laravel 应用程序 testapp 文件夹之外创建 htaccess?或里面
  • 你可以在你的 env 文件那里创建 htaccess 文件
  • 是的,我已经在那里创建了。它仍然重定向到我的主站点
【解决方案3】:

关注此tutorial 它适用于任何共享托管计划。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-03-29
    • 2014-07-19
    • 2018-04-13
    • 1970-01-01
    • 1970-01-01
    • 2013-02-17
    • 1970-01-01
    • 2018-06-05
    相关资源
    最近更新 更多