Nginx issues - 500 error for media and panel 'No input file specified'

I’ve been struggling to get Kirby 3 up and running on a Digital Ocean box that’s using Nginx. All the appropriate pages are appearing but the Media is giving me a “500 (Internal Server Error)” in dev tools. The url’s to the images is correct. All files permissions and ownership are as they should be.

As well as 500 errors I cannot get the panel to appear at all.

Is there a complete example of an Nginx config that we should be using for Nginx? - I found one for Kirby 3 and 2 elsewhere in the forum but they were not sufficient

Thanks

Here are the two important parts in our nginx config for the Kirby website that get everything up and running:

# site links
location /
{
        try_files $uri $uri/ /index.php$is_args$args;
}

# pass the PHP scripts to FastCGI server listening on the php-fpm socket
location ~ \.php$ {
        try_files $uri = 404;
        fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
}

The rest is pretty standard stuff.

1 Like

Check your php-fpm log files to see what they say.

Thanks Bastian,

This worked for resolving all the urls with nginx file but my main issue that I found was actually file permissions and ownership. This article really helped:

I had to run:

HTTPDUSER=$(ps axo user,comm | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\  -f1)

sudo setfacl -dR -m u:"$HTTPDUSER":rwX -m u:$(whoami):rwX media content
sudo setfacl -R -m u:"$HTTPDUSER":rwX -m u:$(whoami):rwX media content

‘Media’ and ‘Content’ being the folders that needed this ran on as well as ‘sessions’ ‘accounts’ ‘content’ inside the ‘site’ folder

Seems to be working now and no further issues.

For those not familiar with the “pretty standard stuff”: make sure you include
client_max_body_size 32M; or some other value if you want to upload files larger than 2M.

I am still having problems getting Kirby 3 running on a NGINX server.

The site is showing up, but no image will load, and also I can’t access the panel. It will just say

The panel assets cannot be installed properly. Please check permissions of your media folder.

This page has no styling at all – it is all written in a serif font. All permissions for the folders are set, though (content, media, site/accounts, site/sessions).

Any ideas?

My server block looks like this

server {

        root /var/www/MY_DOMAIN.com/html;

        server_name MY_DOMAIN.com www.MY_DOMAIN.com;


        index index.php index.html index.htm index.nginx-debian.html;


        # site links
        location /
        {
                try_files $uri $uri/ /index.php$is_args$args;
        }

        # pass the PHP scripts to FastCGI server listening on the php-fpm socket
        location ~ \.php$ {
                try_files $uri = 404;
                fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
        }

      

        listen [::]:443 ssl; # managed by Certbot
        listen 443 ssl; # managed by Certbot
        ssl_certificate /etc/letsencrypt/live/MY_DOMAIN.com/fullchain.pem; # managed by Certbot
        ssl_certificate_key /etc/letsencrypt/live/MY_DOMAIN.com/privkey.pem; # managed by Certbot
        include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
        ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}

server {
        if ($host = www.MY_DOMAIN.com) {
            return 301 https://$host$request_uri;
        } # managed by Certbot

        if ($host = MY_DOMAIN.com) {
            return 301 https://$host$request_uri;
        } # managed by Certbot

        listen 80;
        listen [::]:80;

        server_name MY_DOMAIN.com www.MY_DOMAIN.com;
        return 404; # managed by Certbot
}

What are the permissions set for these folders and what is there ownership?

Hi Texnixe

Thank you for your help. I just found the issue: My composer.json has not been uploaded to the server. The NGINX setting above works fine!