laravel-5 - 如何正确上传 Laravel 5 应用程序到服务器?

标签 laravel-5

我是 Laravel 5 的新手,并且意识到发生了很多变化,我更熟悉 Laravel 4。我刚刚尝试将我的网站上传到实时 VPS,我设法更改了 index.php 中的 URL server.php 但我不断收到这些错误:

NetworkError:

这让我相信还有一些我应该更改但没有更改的内容,因为这些文件确实存在,并且我的应用程序在我的本地主机上运行得很好。

此外,除了我的主页之外,当我点击其链接时,其余页面都说找不到。

这是我的文档结构:

Document Structure

index.php

<?php

require __DIR__.'/../*********/bootstrap/autoload.php';

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

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

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

$response->send();

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

server.php

<?php
/**
 * Laravel - A PHP Framework For Web Artisans
 *
 * @package  Laravel
 * @author   Taylor Otwell <<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6d190c1401021f02191a0801012d0a000c0401430e0200" rel="noreferrer noopener nofollow">[email protected]</a>>
 */

$uri = urldecode(
    parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
);

// This file allows us to emulate Apache's "mod_rewrite" functionality from the
// built-in PHP web server. This provides a convenient way to test a Laravel
// application without having installed a "real" web server software here.
if ($uri !== '/' and file_exists(__DIR__.'/../public_html'.$uri))
{
    return false;
}

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

最佳答案

您必须遵循以下步骤才能将 Laravel 中的本地服务器移至实时服务器。

  1. 将所有公用文件夹数据移至根目录

  2. 在index.php中将路径更改为 需要 DIR.'/../bootstrap/autoload.php';需要 DIR.'/bootstrap/autoload.php';

    并且

    $app = require_once DIR.'/../bootstrap/app.php';到 $app = require_once DIR.'/bootstrap/app.php';

    并将文件权限设置为744

  3. 在 .htaccess 文件中,在 RewriteEngine On 后添加以下代码。

    RewriteBase/

  4. 更改 .env 文件中的参数。

关于laravel-5 - 如何正确上传 Laravel 5 应用程序到服务器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29260959/

相关文章:

laravel - 捕捉 Eloquent 错误

laravel-5 - 如何在 Laravel 中创建自己的类助手?

javascript - ajax 请求在 laravel 中只能运行一次

api - Laravel 中 REST API 使用的最佳身份验证方法是什么?

api - 使用 Laravel API 测试 Laravel 5.2.x 自定义包

laravel - Eloquent - 有偏差的随机选择记录

php - 日历邀请在 outlook 中作为 ICS 文件接收 - Laravel

php - 重定向到 Controller 操作,操作未定义

php - 如何在 Laravel 5.2 中使用多重授权

php - Laravel Eloquent 按关系排序