laravel 5.5 blank page after deployment

Published 1 month ago by viclyapunov

Hi everyone, I have a local dev environment on Homestead that works very well.

However, when I deploy it to the production server, I do everything as described in https://laravel.com/docs/5.5 I get a blank page instead of my view.

$ php artisan route:list
+--------+----------+-----------------+------+---------+--------------+
| Domain | Method   | URI             | Name | Action  | Middleware   |
+--------+----------+-----------------+------+---------+--------------+
|        | GET|HEAD | /               |      | Closure | web          |
|        | GET|HEAD | api/user        |      | Closure | api,auth:api |
|        | GET|HEAD | articles        |      | Closure | web          |
|        | GET|HEAD | ria             |      | Closure | web          |
|        | GET|HEAD | ria-lenta       |      | Closure | web          |
|        | GET|HEAD | ria-lenta-links |      | Closure | web          |
+--------+----------+-----------------+------+---------+--------------+

And the code of the route is:

Route::get('/articles', function () {
    $articles = Article::all()
        ->sortByDesc("id");

    return view('articles.index', array('articles' => $articles));
});

Could you please point me where to start digging? the nginx error.log is absolutely empty.

Best Answer (As Selected By viclyapunov)
dlucian

The fastest way to start debugging this is to open the main index.php file that nginx points to and add a simple

die('Working');

in it. If you see it, it's a PHP/Laravel issue. If you don't, it's an nginx issue.

After this, if you see the "Working" message, tail storage/logs/laravel.log file to see if anything got dumped there. The production environment isn't very verbose when it comes to errors.

ejdelmonico

Is your nginx config correct? Did you run migrations and create your .env? Are you serving from the public directory? Did you use leading slashes for assets? There are a bunch of questions related to a blank page. Maybe increase the details of the question...like the steps you took and how it is hosted.

ejdelmonico

Here is an example config:

# FORGE CONFIG (DOT NOT REMOVE!)
#include forge-conf/YOUR-SITE/before/*;

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name YOUR-SITE;
    root YOUR-SITE root;

    # FORGE SSL (DO NOT REMOVE!)
    ssl_certificate /etc/nginx/ssl/YOUR-SITE/YOUR-SITE-cert/server.crt;
    ssl_certificate_key /etc/nginx/ssl/YOUR-SITE/YOUR-SITE-cert/server.key;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA';
    ssl_prefer_server_ciphers on;
    ssl_dhparam /etc/nginx/dhparams.pem;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";

    index index.html index.htm index.php;

    charset utf-8;

    # FORGE CONFIG (DOT NOT REMOVE!)
   #include forge-conf/YOUR-SITE/server/*;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log off;
    error_log  /var/log/nginx/YOUR-SITE-error.log error;

    error_page 404 /index.php;

    if ($request_uri ~* "^(.*/)index\.php/?(.*)") {
        return 301 "$1$2";
    }

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }

    location ~ /\.(?!well-known).* {
        deny all;
    }
}

# FORGE CONFIG (DOT NOT REMOVE!)
#include forge-conf/YOUR-SITE/after/*;
dlucian

The fastest way to start debugging this is to open the main index.php file that nginx points to and add a simple

die('Working');

in it. If you see it, it's a PHP/Laravel issue. If you don't, it's an nginx issue.

After this, if you see the "Working" message, tail storage/logs/laravel.log file to see if anything got dumped there. The production environment isn't very verbose when it comes to errors.

viclyapunov

@dlucian , thanks a lot, your answer helped me to solve the problem :) turned out, It was a nginx misconfiguration.

jlrdw
jlrdw
1 month ago (199,820 XP)

@viclyapunov

How about

mark as answered so people will know. Give @dlucian credit.

Please sign in or create an account to participate in this conversation.