Unable to logon after updating Centos

I’ve just updated Centos v7.9 in my lab set-up and I’m now unable to logon. Logon page loads but throws me back to the logon prompt when clicking Logon. I’d installed v23.0.2 before running yum -y updates. Running as VM and I took a snapshot before so can easily go back.

Any idea where should I start looking? A lot of updates were installed…

I’m pretty new to Nextcloud and not exactly a guru with Centos Linux either :frowning:

Isolated it to upgrading php and modules. The following updates work fine:

yum -y update ImageMagick6-libs.x86_64
yum -y update MariaDB-client.x86_64
yum -y update MariaDB-common.x86_64
yum -y update MariaDB-compat.x86_64
yum -y update MariaDB-server.x86_64
yum -y update bind-export-libs.x86_64
yum -y update cronie.x86_64
yum -y update cronie-anacron.x86_64
yum -y update cyrus-sasl-lib.x86_64
yum -y update epel-release.noarch
yum -y update galera-4.x86_64
yum -y update httpd.x86_64
yum -y update httpd-tools.x86_64
yum -y update kernel.x86_64
yum -y update kernel-tools.x86_64
yum -y update kernel-tools-libs.x86_64
yum -y update libzstd.x86_64
yum -y update openldap.x86_64
yum -y update openssl.x86_64
yum -y update openssl-libs.x86_64
yum -y update polkit.x86_64
yum -y update python-perf.x86_64
yum -y update remi-release.noarch
yum -y update systemd.x86_64
yum -y update systemd-libs.x86_64
yum -y update systemd-sysv.x86_64

But update php and modules and unable to logon:

yum -y update php.x86_64
yum -y update php-bcmath.x86_64
yum -y update php-cli.x86_64
yum -y update php-common.x86_64
yum -y update php-fpm.x86_64
yum -y update php-gd.x86_64
yum -y update php-gmp.x86_64
yum -y update php-intl.x86_64
yum -y update php-json.x86_64
yum -y update php-mbstring.x86_64
yum -y update php-mysqlnd.x86_64
yum -y update php-pdo.x86_64
yum -y update php-process.x86_64
yum -y update php-sodium.x86_64
yum -y update php-xml.x86_64

It’s late now so will return to it over the next few days.

I’m still looking for any assistance on this because it’s repeatable on both my development and client’s production environment. Basically, we can’t install any further updates because it breaks Nextcloud logon. I’ve just tried installing PHP OPCache on the live system which caused all the PHP modules to update and now we can’t logon.

To be honest, this is what worries me about Nextcloud community even for a small company like this. A seemingly simple task breaks the system :frowning:

I’m maybe first looking for advice as to how you debug problems like this?

I’ve resolved this by re-installing PHP. For the record, this is what I did. Haven’t a clue why this fixed it but I find that’s Linux all over :wink:

What Notes
Stop services systemctl stop nginx mariadb php-fpm
Remove php modules yum -y remove php php-fpm php-dom php-gd php-mbstring php-posix php-session php-simplexml php-zip php-mysql php-intl php-bcma php-gmp php-imagick php-bcmath
Updates installed yum y- update
Install remi repository yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
Install yum utilities (yum-config-manager) yum -y install yum-utils
Query PHP versions yum --disablerepo=* --enablerepo=remi-safe list php[7-9][0-9].x86_64
Configure Yum to install PHP v7.4 yum-config-manager --enable remi-php74
Install PHP and modules needed for Nextcloud (more below) yum -y install php php-fpm php-dom php-gd php-mbstring php-posix php-session php-simplexml php-zip php-mysql php-intl php-gmp php-imagick php-bcmath php-opcache
Configure php-fpm to use nginx and uncomment env variables nano /etc/php-fpm.d/www.conf
PHP memory_limit increased to 512M nano /etc/php.ini
Set nginx as owner on PHP session folder chown -R root:nginx /var/lib/php/session/
Enable php-fpm service systemctl enable php-fpm
Start services systemctl start nginx mariadb php-fpm

Although I marked the above as the solution, I’m not 100% sure it is because I’ve just come to update again and the same problem occurred - and the fix didn’t work.

I now suspect it’s some local caching issue in the browser after an update because if instead of logging in using the same browser/profile, I launch a guest profile (or open Nextcloud on a different computer), I’m able to logon fine.

30 minutes later and I still can’t logon from the same browser. I’m guessing that if I cleared my browser cache, it would start working but don’t want to do that. I’ll wait 24 hours and see if I can then logon.

Later… yes, magically after about an hour, I was able to logon. Something cached in the browser that doesn’t work after you’ve upgraded Linux/PHP packages.

This one rumbles on but I’ve now really tracked it down. It’s nothing at all to do with Nextcloud… It’s, effectively, a bad configuration of php-fpm on nginx that’s been around a long time. This thread discusses it:

nginx/PHP file permission problems after yum update - CentOS

When using pho-fpm on nginx, you have to change the ownership of the session folder:

chown -R root:nginx /var/lib/php/session/

The problem is that when php-fpm updates, it resets the permissions on this folder back to root:apache.

You could try to remember to run the chown command each time you update, but a better solution is to configure php-fpm to use it’s own session folder:

mkdir /var/lib/php/nginx-session
chown -R root:nginx /var/lib/php/nginx-session/
chmod -R 770 /var/lib/php/nginx-session
nano /etc/php-fpm.d/www.conf - edit save.path near the end
systemctl restart php-fpm

Note the chmod command - most documentation doesn’t mention this. The default permissions from the mkdir aren’t correct.

Once this change is made, php-fpm can be updated and the session continues to work.

1 Like