Nginx – Laravel on nginx+php-fpm returns blank page

nginxPHPphp-fpm

I'm having this issue with Laravel which is served by nginx + php-fpm, it's just returning a blank page. Neither nginx nor php nor laravel are logging any errors at all.

When running the index.php with the CLI, it will return the welcome page.

The laravel stack is untouched, all error reporting/displaying/logging is turned on.

Below is my nginx vhost:

server {
    listen 801;
    server_name _;

    root /path/to/laravel/public;
    index index.html index.html index.php;

    charset utf-8;

    gzip                    on;
    gzip_http_version       1.1;
    gzip_disable            "MSIE [1-6].";
    gzip_vary               on;
    gzip_proxied            expired no-cache no-store private auth;
    gzip_comp_level         9;

    fastcgi_buffers         8 16k;
    fastcgi_buffer_size     32k;
    fastcgi_read_timeout    180;

    # serve static files directly
    location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
            access_log      off;
            expires         max;
    }

    location / {
            index  index.html index.htm index.php; #try static .html file first
            ##try_files $uri $uri/ /index.php;  <<Wrong!! this will break bundles like OneAuth for example
            try_files $uri $uri/ /index.php?q=$uri&$args;
    }

    # catch all
    error_page      404 /index.php;

    #set client_max_body_size
    client_max_body_size 25m;
    #set client_body_buffer_size
    client_body_buffer_size 128k;

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

My problem was that app/storage had the wrong permissions. So if you get the same errors as myself, blank page, try chmod 0777 the entire app/storage folder.

sudo chmod -R 0777 app/storage

Best Answer

OP stated that his working solution is sudo chmod -R 0777 app/storage.

While it solved the problem, it is never the solution. The proper way is set the group as www-data and give it write permission.

chown -R www-data app/storage
chmod -R 0770 app/storage

For details explanation about chmod 777 and permissions on a Linux webserver, see this answer: What permissions should my website files/folders have on a Linux webserver?