2

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
masegaloeh
  • 18,236
  • 10
  • 57
  • 106
Raiu
  • 161
  • 1
  • 1
  • 3
  • Did you try to log PHP error via configuration with FPM config catch_workers_output = yes option. just a reminder: you can use xtail for multiple log file such as xtail /var/log/* – risyasin Nov 04 '14 at 17:11

3 Answers3

3

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?

masegaloeh
  • 18,236
  • 10
  • 57
  • 106
0

Try change your 'try_files' argument to the following:

try_files $uri $uri/ /index.php?$args;
jaseeey
  • 1,462
  • 16
  • 20
  • Tried, but sadly no change. – Raiu Jan 23 '14 at 22:06
  • Have you definitely got 'display_errors' and 'error_reporting' set using php_admin_flag and php_admin_value in your PHP-FPM pool configuration? The Nginx configuration for Laravel is really quite basic, as long as you're not using a sub-directory. – jaseeey Jan 23 '14 at 22:09
  • the phpinfo() returns: display_errors On, display_startup_errors On. So i guess it should be working – Raiu Jan 23 '14 at 22:10
  • Try setting these in your PHP-FPM pool configuration file: php_admin_flag[display_errors] = on (and) php_admin_value[error_reporting] = E_ALL (split them on their own lines, and remove the 'and'). Make sure you restart the 'php-fpm' service and then try again. – jaseeey Jan 23 '14 at 22:11
  • Didnt help the reporting. This my current pool.conf file: http://pastebin.com/mc6P0PDy – Raiu Jan 23 '14 at 22:16
  • I tried testing that the config worked by add "die('test');" on the top of the index.php in public. And that actually printed out test. – Raiu Jan 23 '14 at 22:21
  • I had the same issue, but I was trying to get it working under a sub-directory using Nginx and PHP-FPM. I tried your configuration with my PHP-FPM setup and it seems to work fine. Are you able to serve other content from the web server? What happens if you adjust the web root and remove 'public' and add 'autoindex on;' under the location block? Does it show the list of files? – jaseeey Jan 23 '14 at 22:24
  • One last thing, is your 'app/storage' directory writable by the web server? You could try running 'chmod -R 0777 app/storage'. – jaseeey Jan 23 '14 at 22:33
  • serving other content isnt a problem and listing of the content works. Finally found the problem. I had to specify the 'url' in the app.php config file. I didnt need to do that before. So embarassing that i dont figure that one out before... – Raiu Jan 23 '14 at 22:42
  • Hmm, that's a little bit weird. I've never had to do that... ever. Glad you sorted it out though! – jaseeey Jan 23 '14 at 22:42
  • Idd, i know some frameworks have the option to set the url. But in my experience it's mostly for show. Thanks for your help and support Jason – Raiu Jan 23 '14 at 22:45
  • I never read your comment about the chmod on app/storage until i had tried it myself after some trial and error. The chmod was probably the true enemy of my app. – Raiu Jan 23 '14 at 23:01
  • It was the only additional thing I had to do on top of your configuration on my server. It's usually the culprit, but I'm unsure why you weren't getting any errors as the error screen came up straight away for me. – jaseeey Jan 24 '14 at 00:02
0

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
Raiu
  • 161
  • 1
  • 1
  • 3