【问题标题】:Blank white page - laravel5 upload to server空白白页 - laravel5 上传到服务器
【发布时间】:2015-09-22 13:40:19
【问题描述】:

我已将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。我需要帮助。

【问题讨论】:

  • 当我在 (/var/www/html/siddhartha/CMS) localhost 中运行 php artisan serve 时出现错误 PHP 致命错误:require(): Failed opening required '/var/www/html/ siddhartha/CMS/app/http/helpers/backend/helpers.php' (include_path='.:/usr/share/php:/usr/share/pear') 在 /var/www/html/siddhartha/CMS/vendor /composer/autoload_real.php 第 54 行

标签: php laravel laravel-5 cpanel


【解决方案1】:

Laravel 5 不应该在共享主机上工作。这也是真的 重要 Laravel 5 使用 php 5.5.9,这在共享主机上不可用。

您需要设置文件夹存储和引导的权限 - 转到cpanel中的文件管理器右键单击文件夹并选择777权限,并在应用时确保选中所有包含文件的框以获得相同的权限。 至于作曲家更新或安装和 php artisan,您需要制作一个 php 脚本来在 bash 中运行命令。这是共享主机的解决方法,但它可能并不总是有效。 或者,如果您有 shell 访问权限,那么您可以执行 composer install/php artisan 并从该 shell 更改权限。

【讨论】:

  • 右键单击演示文件夹我发现更改权限,我做了 777 并访问了 mydomain.com/demo 但仍然有空白页
  • 你明白你必须去那个文件夹中的 shell 并运行 composer install/update 和 artisan 命令吗?
  • 在您的 laravel 文件夹中新建一个 php 文件并添加以下代码 &lt;?php $output = shell_exec('composer install'); echo "&lt;pre&gt;$output&lt;/pre&gt;"; ?&gt; 然后在 shell exec composer update 和 php artisan 中运行。此外,为了让作曲家工作,您可能需要下载它,并且您需要使用这个 shell exec 运行其他命令来获取作曲家并运行 php composer.phar install/update
  • 我应该把它放在应用目录或应用目录之外
  • 在您拥有应用存储等文件夹的 laravel 文件夹中
【解决方案2】:

在您的demo 文件夹中,创建一个新文件夹,在本例中为CMS。将你项目的所有contents移动到CMS文件夹内,除了public目录的内容,然后,copypublic目录的所有内容都移到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:cachephp artisan config:clear 真的没有必要对.htaccess 进行更改,也不需要给777 授予storage 文件夹的权限。我总是将这个设置用于我的laravel 项目。它也应该适用于您的情况。

【讨论】:

  • 我的结构和你上面提到的 CMS->app,bootstrap,config,resources 等一样
  • 如何通过c-panel给777权限到服务器中的存储文件夹,可以吗?
  • 是的,它可能......当您右键单击该文件夹时,必须有一些选项,如change permission。 P.S 检查你是否使用了正确的php 版本
  • 右键单击演示文件夹我发现更改权限,我做了 777 并访问了 mydomain.com/demo 但仍然有空白页
  • 您使用的是哪个php 版本。它必须大于5.5
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-05-22
  • 1970-01-01
  • 2014-09-19
  • 2018-02-23
  • 1970-01-01
  • 1970-01-01
  • 2014-11-26
相关资源
最近更新 更多