繁体   English   中英

空白白页 - laravel5 上传到服务器

[英]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

我的debugapp文件中设置为 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目录下的所有内容copyCMS目录层级。 您的文件夹结构将看起来像。

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:cachephp artisan config:clear真的不需要在.htaccess做任何更改,也给storage文件夹777权限。 我总是在我的laravel项目中使用这个设置。 它也应该适用于您的情况。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM