Can't get Grocy working, getting unknown 50x error

I am trying to set up Grocy on a Fedora 29 LXC container.

I installed nginx, sqlite, php and php-pdo on Fedora (i chose this because neither Debian nor CentOS had PHP 7.2 in their repos) and unzipped the latest release in /var/www, and set the Nginx root to /var/www/public, as the README instructed.

When i load the page i get a 404 error, along with this in /var/log/nginx/error.log:

2018/12/30 23:27:13 [error] 396#0: *69 open() "/var/www/public/50x.html" failed (2: No such file or directory), client: CLIENT IP, server: _, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/run/php-fpm/www.sock", host: "HOST IP"

I understand that it can't find the error html for 50x errors and that this is the cause of the 404 error, but what error am i getting then?

Here is my /etc/nginx/nginx.conf: # For more information on configuration, see: # * Official English Documentation: http://nginx.org/en/docs/ # * Official Russian Documentation: http://nginx.org/ru/docs/

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;

    server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  _;
        root         /var/www/public;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location / {
            alias /var/www/public;
#            index index.php index.html index.htm;
            index index.htm index.html /index.php;
#            try_files $uri $uri/ @grocy;
            try_files index.php $uri $uri/ @grocy;
#            autoindex on;
        }

        location @grocy {
            rewrite /(.*)$ /index.php?$query_string last;
        }

        location ~ /(.+.php)(.*)$ {
            fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
            fastcgi_param SCRIPT_FILENAME $request_filename;
            include /etc/nginx/fastcgi_params;
            charset utf8;
        }


        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }
}

I didn't know what else to include, so let me know if i have missed something.

Posted Dec 30, 2018, 11:42 PM UTC

412
justpeter•

I would check that permissions are set properly on your php files and the public directory. This is the most common 5xx error I run into with new installs.

(Also, it's just a few extra commands to add an extra apt repo and get PHP 7.2 on a Debian system!)

1
SphereUnfilledOP•

I think the permissions are correct. I ran

find . -type f -exec chmod 644 {} +
find . -type d -exec chmod 755 {} +

In /var/www (borrowed it from the internet) and have recursively given ownership to the nginx user and group.

ls -l gives me this. The permissions for files and folders are the same in all subdirectories.

-rw-r--r--  1 nginx nginx  1772 Sep 30 15:26 app.php
-rw-r--r--  1 nginx nginx  3436 Dec 30 09:19 config-dist.php
drwxr-xr-x  2 nginx nginx  4096 Nov 21 19:02 controllers
drwxr-xr-x  5 nginx nginx  4096 Dec 30 23:08 data
-rw-r--r--  1 nginx nginx 59767 Nov 21 19:02 grocy.openapi.json
drwxr-xr-x  2 nginx nginx  4096 Dec 30 09:19 helpers
-rw-r--r--  1 nginx nginx  1090 Jul 16 11:20 LICENSE
drwxr-xr-x  7 nginx nginx  4096 Nov 26 19:21 localization
drwxr-xr-x  2 nginx nginx  4096 Oct  6 10:24 middleware
drwxr-xr-x  2 nginx nginx  4096 Nov 21 19:02 migrations
lrwxrwxrwx  1 nginx nginx     7 Dec 30 22:11 publi -> public/
drwxr-xr-x  8 nginx nginx  4096 Oct  6 10:44 public
-rw-r--r--  1 nginx nginx  6975 Nov 21 19:02 README.md
-rw-r--r--  1 nginx nginx  9473 Nov 21 15:24 routes.php
drwxr-xr-x  2 nginx nginx  4096 Nov 26 19:21 services
-rw-r--r--  1 nginx nginx   922 Jul 25 15:48 update.sh
drwxr-xr-x 19 nginx nginx  4096 Dec 30 09:26 vendor
-rw-r--r--  1 nginx nginx    59 Dec 30 09:20 version.json
drwxr-xr-x  4 nginx nginx  4096 Nov 26 19:21 views
1
Ioangogo•

It's SELinux, I am doing something you shouldn't and disabling enforcement, but there are ways, putting "selinux PHP sqlite" into Google should give some pointers on how to do it properly

1
justpeter•

Is there anything in the PHP-FPM log (separate from nginx's log file)?

1
peregm•

The error_page 500 502 503 504 directive is looking for a file that does not exist, so that is why it gives an error.

That directive means that when there is a 50x error, it shows the specified page (50x.html). So, basically, just creating a regular HTML file with an error message in /var/www/public/50x.html or simply deleting the error_page directive should fix the issue.

Edit: formatting

1
SphereUnfilledOP•

I realize i wasn't clear on what i was asking. I commented out the the 50x directive and i got a blank page, so i know that is the error"familiy" i am getting, but not which one. Does the default 50x file show a different page for each error? I expect that and that is the reason i didn't just make one, as getting a 500 error message for a 502 error would complicate things.

I am not at all experienced with web servers.

1
peregm•

Yeah, but the error in the log you provided is because of this. If you comment it, you should see another error in the log stating the cause of the 50x.

1
SphereUnfilledOP•

That makes a lot more sense! I will try that when i get back home. Thanks!

1
berrnd•

There must be an error message for the initial 500 error in the php-fpm log or somewhere...

config.php copied/created in /data?
SQLite version 3.8.3 or higher installed?

1
MethodMan24•

I would recommend enabling debug mode so you can verify if it is a permission error or not. To enable debug mode is to add debug at end of the error log configuration.

error_log /var/log/nginx/error.log debug;

It is recommended to not do this in production as you are exposing a lot of information

1
Ieatapostrophes•

DId you ever get this to run? Because when setting it up today, I got a blank page at first as well. Checking my apache logs, I realized that when I copied the config file to /data/config.php, as per the README, I accidentally moved it instead. Apparently the app is still looking for the config-dist.php in the folder above, which it didn't find and therefore presented me with a blank page instead. So copying that file back and renaming it to config-dist.php did the trick. Maybe that was/is your issue as well.

1
SphereUnfilledOP•

I am sorry i never answered you guys. I got caught up in work, and then i messed up my server while upgrading my RAM. I will answer if your suggestions work out when i have the time to figure this out.

2
Ieatapostrophes•

No worries, friend.

1