简体   繁体   中英

Blank white page - laravel5 upload to server

I have uploaded the Laravel-5 project to server inside demo folder but when I visited mydomain.com/demo I got nothing ie blank page. I cannot actually find what is happening, I think it is because of .htaccess file or something else.

My folder structure inside demo folder is like below:

在此处输入图片说明

My .htaccess file:

<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>

My index.php file is like below:

<?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);

when i view error_log file i found these at last line

[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

My debug is set true inside app file. I need help.

Laravel 5 is not supposed to work on shared hosting. Also this is really IMPORTANT Laravel 5 uses php 5.5.9 that is not available on shared hostings.

You need to setup the permissions for the folders storage and bootstrap - go to file manager in your cpanel right click on the folders and select 777 permissions and when apply make sure to check the box that all included files to get the same permissions. as for composer update or install and php artisan you need to make a php script to run the commands in bash. This is the workaround for shared hosting but it may not work all the times. Or if you have shell access then you can do the composer install/ php artisan and change permissions from that shell.

Inside your demo folder, make a new folder, CMS in the case. Move all the contents of your project inside the CMS folder except the contents of public directory, Then, copy all the contents of public directory in the level of CMS directory. Your folder structure will then look something like.

demo
  CMS
    app
    bootstrap
    config
    database
    resources
    storage
    and so on....
  assets
  robots.txt
  index.php

and your index.php

require __DIR__.'/CMS/bootstrap/autoload.php';
 $app = require_once __DIR__.'/CMS/bootstrap/app.php'; 

one more thing, after completing these setup, run php artisan config:cache and php artisan config:clear There is really no need to do changes in .htaccess and also give 777 permission to storage folder. I always use this setup for my laravel project. It should work in your case too.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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