Session storage directory "/var/www/sites/hometownweb/site/sessions" is not writable

I know this question has been asked several times before, but none of the solutions given seem to have helped.

Can you please help me understand what I’m doing wrong?

Here’s my environment:
OS: Fedora Workstation 41
Kirby Installation method: Kirby CLI using PlainKit
Web Server: nginx
Installation Directory: /var/www/sites/hometownweb (hometownweb is the root/base of the install)

  • The directory sites all the way down is owned by nginx:nginx
  • The directory sites has permissions 775
  • The directory hometownweb all the way down is set to 777 (I would never do this in production, but I’m getting frustrated with it not working).

The base works fine. It errors when trying to access the backend (/panel)

hometown.conf (nginx config file for site)

server {
  listen 80;
  index index.php index.html;
  server_name hometownweb;
#   root /home/funky/projects/PHP/hometownweb;
  root /var/www/sites/hometownweb;

  access_log /var/log/nginx/hometownweb.access.log;
  error_log /var/log/nginx/hometownweb.error.log error;

  default_type text/plain;
  add_header X-Content-Type-Options nosniff;

  rewrite ^/(content|site|kirby)/(.*)$ /error last;
  rewrite ^/\.(?!well-known/) /error last;
  rewrite ^/(?!app\.webmanifest)[^/]+$ /index.php last;

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

  location ~* \.php$ {
    try_files $uri =404;
    fastcgi_pass unix:/run/php-fpm/www.sock;
    include fastcgi.conf;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_param PATH_INFO $fastcgi_path_info;
  }
}

So when you are running your site locally, what processes are involved and what users are running those processes?

I think with Nginx you get at process for nginx and one or maybe several processes for php(or php-fpm maybe)? Are they all running with the nginx user?

I’ve set up php-fpm to run as nginx for both user and group in the /etc/php-fpm.d/www.conf file.

How can I tell what user is ACTUALLY being used? It doesn’t seem to show in the error log or anything.

check with ´ps aux | grep php-fpm`

Looks like root is running the master process and nginx is running each pool.

But, I guess one question is, if everything is set to 777, does it matter who it’s run under, as all user, group, and other have full access?

What do you get if you run echo exec('whoami') in a template? I wonder if it is makes sense that the master process runs as root

I altered the default template and refreshed the home page.

Also, since I didn’t mention it in the original post.

When I go to /panel, it forwards me to /panel/installation.

Is it possible that /panel will work if we manually do whatever is needed for the installation?
What is the installation process trying to do?

As long as no user exists, you will need to do the installation, which consists of creating the first user. If you are on a remote server, you need to allow this first in your config. On a local server, it should be no problem.

But if you get an error message that the sessions folder is not writable, then you need to fix that first.

It’s my local computer.

Here is what shows up in the error log when I hit http://hometownweb/panel (and it forwards to http://hometownweb/panel/installation)

And before it’s asked, I know it’s not a “legit” domain name (FQDN), but I have my /etc/hosts file listening for hometownweb and directing to 127.0.0.1, and nginx config file listening for hometownweb

Error seems to happen here:

Can you try to do a reduced test where you call is_writable($path_to_sessions_folder) (with the correct path as a string) without going through Kirby code at all? You can do that by editing your site’s index.php and commenting out all Kirby code including requires.

<?php

$path_to_sessions_folder = "/var/www/sites/hometownweb/site/sessions";
var_dump(is_writable($path_to_sessions_folder));
exit; // stops execution here

require 'kirby/bootstrap.php';
echo (new Kirby)->render();

It might also be worth checking, in the FileSessionStore constructor, what the values of $path and $this->path are (especially since one of those values is used in the error message, but it’s the other one that is actually checked). You can do that by adding some var_dump calls in kirby/src/Session/FileSessionStore.php.

I’d also check the PHP configuration and make sure all error reporting is turned on:

and that the values of doc_root and open_basedir are not strange.

First off, thank you to everyone for taking the time to try to help me. I really appreciate it.

error_reporting was (and still is) set to: E_ALL & ~E_DEPRECATED & ~E_STRICT
display_errors was set to Off, now set to On
display_startup_errors was set to Off, now set to On

After changing the two settings, I restarted both nginx and php-fpm.

Here is the is_writable in the index file along with the browser output:

I can only do one embed per post, so I’ll post the FileSessionStore in the next post.

Here is the FileSessionStore file changes and browser output:

So I think this confirms that it’s not a Kirby-specific problem, but rather a problem with your local server and PHP setup that results in this folder not being writable.

Dunno what else to suggest, aside from checking everything from folder permissions to PHP configuration to Nginx & fastcgi configuration. There must be some access rule at one of the execution levels that prevents writing to disk (to this specific folder or maybe even to any folder).