Changing Apache user blocks nextcloud login?

I’ve installed the current Nextcloud on Debian 11.6 and Apache 2 and it was all working correctly.

I need to switch the user that apache runs under from www-data to another user. I’ve set the user and group in the apache env file and chmoded all the filed and directories used by www-data.

Apache loads correctly and I can load the login page of Nextcloud, however when I attempt to log in with a known valid username and password, it appears to load in but I get redirected back to the login screen without any error. I also can’t see any errors in the apache 2 logs or system logs.

Reverting the apache user and file owner to www-data allows the user to log in again. If the user is logged in before the switch, reloading after the switch seems to invalidate the current session, something which does not seem to happen just from shutting down and restarting the apache server.

Does anyone have any idea what’s going on?

Thanks.

Could you take a look in the nextcloud.log, it should be under your nextcloud data folder, for example, /var/www/html/nextcloud/data/nextcloud.log.

Thanks, I hadn’t thought to look under data for the log file.

Turns out I’d missed the session file under /var/lib/php/sessions, chowning that (I said chmoded above for some reason) sorted the issue.

1 Like

Are you running php-fpm?

If that is the case, did you change the user and group in:

/etc/php/<version>/fpm/pool.d/www.conf