gpt4 book ai didi

php - 将 Laravel 4 上传到共享主机

转载 作者:搜寻专家 更新时间:2023-10-31 21:51:56 26 4
gpt4 key购买 nike

我想将我的 laravel 4 项目上传到共享,我创建了一个单独的 laravel 文件夹,上传了除 public 文件夹之外的所有内容,然后将 public 文件夹中的所有内容移动到我的 public_html 文件夹中。

我修改了public_html中的index.php,修改了laravel文件夹中的server.php。有没有我错过的步骤,因为当我运行我的页面时我仍然得到一个空白页面。

public_html/index.php

<?php
/**
* Laravel - A PHP Framework For Web Artisans
*
* @package Laravel
* @author Taylor Otwell <taylorotwell@gmail.com>
*/

/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader
| for our application. We just need to utilize it! We'll require it
| into the script here so that we do not have to worry about the
| loading of any our classes "manually". Feels great to relax.
|
*/

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

/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let's 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 these users.
|
*/

$app = require_once __DIR__.'../laravel/bootstrap/start.php';

/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can simply call the run method,
| which will execute the request and send the response back to
| the client's browser allowing them to enjoy the creative
| and wonderful application we have whipped up for them.
|
*/

$app->run();

laravel/server.php

<?php

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

$uri = urldecode($uri);

$paths = require __DIR__.'/bootstrap/paths.php';

$requested = $paths['public_html'].$uri;

// 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($requested))
{
return false;
}

require_once $paths['public_html'].'/index.php';

刚开始学习 laravel 将非常感谢您的帮助。

最佳答案

如果文件夹在 public_html 之外并更改 public/index.php 中的路径

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

//$app = require_once __DIR__.'/../../bootstrap/start.php';
$app = require_once __DIR__.'/../../myproject/bootstrap/start.php';

所有文件夹必须位于 public_html 之外,例如 myproject。然后在 public_html 中创建相同的文件夹 myproject 并将 public 的内容直接放在那里。

app/storage 的权限更改为 775

关于php - 将 Laravel 4 上传到共享主机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40157021/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com