我试图让我的laravel5.1应用程序在共享主机上运行,但无论我怎么努力,我都会失败。 我的主机结构在this image给出。 laravel应用程序位于app文件夹下,laravel的公用文件夹内容剪切为public_html。 在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 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 nice to relax.
|
*/
require __DIR__.'/../app/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__.'/../app/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);
现在我没有看到我的索引页面,也没有看到/app/storage/logs/laravel.log中的任何错误。
顺便说一句,我的.htaccess在public_html内容中是:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
答案 0 :(得分:3)
在根目录中创建文件夹laravel将所有数据复制到除公用文件夹
之外的该文件夹然后将公共文件夹中的所有数据复制到文件夹pubic_html
现在在你的public_html文件夹中编辑index.php,如下所示:
require __DIR__.'/../laravel/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__.'/../laravel/bootstrap/app.php';
然后更改Config/database.php
并插入有效的数据库连接数据
答案 1 :(得分:0)
虽然@Adnan的答案可以奏效。重要的是要记住Laravel没有开发用于共享主机。 上载根目录中的应用程序文件夹也会公开配置文件。
这是一个严重的安全问题,应该避免!
仅公开&#39;的内容。文件夹(或/和资源,如果视图在那里)应该在根目录中。所有其他文件必须放在Web根目录之外。
我也知道这并不像看起来那么容易。 但是现在广告的安全性与客户数据相比更重要!
很伤心,你当然可以随心所欲!
希望每个人都有一个美好而快乐的圣诞节!