将Laravel从我的本地主机上传到Godaddy服务器

时间:2018-09-24 06:52:17

标签: php laravel

我在localhost中设置的效果很好。我想将我的Laravel应用上传到我的GoDaddy服务器。我创建了一个FTP,以将Laravel应用程序传输到GoDaddy服务器。正如我在创建FTP帐户时注意到的那样,文件位于/ webroot内部,所以我在/webroot/testapp内部创建了testapp是我的Laravel应用。在Laravel应用程序内部,有一个公用文件夹。正如我在Google上进行的研究所得出的那样,其他人说,仅公共文件夹内必须位于/public_html内,而Laravel应用程序应位于外部。就我而言,它是/webroot。现在,将Laravel应用程序传输到服务器后,我没有分离公用文件夹。我也将其放在testapp文件夹中,因为当我将公用文件夹放在我的testapp文件夹之外并编辑index.php文件时,我的主站点位于WordPress中,这将导致错误。因此,我将公用文件夹添加到了testapp文件夹中。当我尝试在浏览器中运行时,提示“ 404(找不到页面)”,因此我尝试在下面编辑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

3 个答案:

答案 0 :(得分:0)

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

这是共享的托管服务,因此您不能一个人做。问一下。

答案 1 :(得分:0)

在根目录中创建.htaccess文件,并将其添加到下面的代码中:-

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

希望有帮助!

答案 2 :(得分:0)

遵循此tutorial,适用于任何共享托管计划。