我是 Laravel 5 的新手,并且意识到发生了很多变化,我更熟悉 Laravel 4。我刚刚尝试将我的网站上传到实时 VPS,我设法更改了 index.php 中的 URL
和 server.php
但我不断收到这些错误:
这让我相信还有一些我应该更改但没有更改的内容,因为这些文件确实存在,并且我的应用程序在我的本地主机上运行得很好。
此外,除了我的主页之外,当我点击其链接时,其余页面都说找不到。
这是我的文档结构:
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 中的本地服务器移至实时服务器。
将所有公用文件夹数据移至根目录
在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
在 .htaccess 文件中,在 RewriteEngine On 后添加以下代码。
RewriteBase/
更改 .env 文件中的参数。
关于laravel-5 - 如何正确上传 Laravel 5 应用程序到服务器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29260959/