我试图让我的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中的任何错误。
顺便说一下,public_html内容中的my .htaccess是:
<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>
2条答案
按热度按时间nwlqm0z11#
在根目录中创建文件夹laravel,将所有数据复制到除公共文件夹以外的文件夹中
然后将所有数据从公用文件夹复制到文件夹pubic_html
现在编辑public_html文件夹中的index.php,如下所示:
然后更改
Config/database.php
并为数据库连接插入有效数据Good tutorial
ac1kyiln2#
虽然the answer from Adnan可以工作,但要记住,Laravel不是为在共享主机上工作而开发的。上传根目录中的应用程序文件夹也会暴露配置文件。
这是一个严重的安全问题,应该避免!
只有“public”文件夹的内容(或/和资源,如果视图在那里)应位于根目录中。所有其他文件都必须放在Web根目录之外。
我也意识到这并不像看起来那么容易做到。但是现在你的广告和你的客户数据的安全比这更重要!
也就是说,你当然可以做任何你想做的事情。