[英]Blank white page - laravel5 upload to server
我已將Laravel-5
項目上傳到demo
folder
內的服務器,但是當我訪問mydomain.com/demo
我什么也沒有,即空白頁面。 我實際上無法找到正在發生的事情,我認為這是因為.htaccess
文件或其他原因。
我在demo folder
夾中的文件夾結構如下所示:
我的.htaccess
文件:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
我的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__.'/CMS/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__.'/CMS/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');
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
$response->send();
$kernel->terminate($request, $response);
當我查看 error_log 文件時,我在最后一行找到了這些
[22-Sep-2015 09:48:07 America/Detroit] PHP Fatal error: require(): Failed opening required '/home/axilcrea/public_html/demo/CMS/bootstrap/../vendor/autoload.php' (include_path='.:/opt/alt/php54/usr/share/pear:/opt/alt/php54/usr/share/php') in /home/axilcrea/public_html/demo/CMS/bootstrap/autoload.php on line 17
我的debug
在app
文件中設置為 true。 我需要幫助。
Laravel 5 不應該在共享主機上工作。 這也是非常重要的, Laravel 5 使用 php 5.5.9 ,這在共享主機上是不可用的。
您需要設置文件夾存儲和引導程序的權限 - 轉到 cpanel 中的文件管理器,右鍵單擊文件夾並選擇 777 權限,並在應用時確保選中所有包含文件的框以獲得相同的權限。 至於作曲家更新或安裝和 php artisan,您需要制作一個 php 腳本來在 bash 中運行命令。 這是共享主機的解決方法,但它可能無法始終有效。 或者,如果您有 shell 訪問權限,那么您可以執行 composer install/php artisan 並從該 shell 更改權限。
在您的demo
文件夾中,創建一個新文件夾,在案例中為CMS
。 將你的工程中除public
目錄內容外的所有contents
移動到CMS
文件夾內,然后copy
public
目錄下的所有內容copy
到CMS
目錄層級。 您的文件夾結構將看起來像。
demo
CMS
app
bootstrap
config
database
resources
storage
and so on....
assets
robots.txt
index.php
和你的index.php
require __DIR__.'/CMS/bootstrap/autoload.php';
$app = require_once __DIR__.'/CMS/bootstrap/app.php';
還有一件事,在完成這些設置后,運行php artisan config:cache
和php artisan config:clear
真的不需要在.htaccess
做任何更改,也給storage
文件夾777
權限。 我總是在我的laravel
項目中使用這個設置。 它也應該適用於您的情況。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.