NC25 down after upgrading to Ubuntu 22.04.01LTS with PHP8.1

I don’t know if this helps find the root cause (I’m just digging around):

root@behome:/var/www/nextcloud# sudo -u www-data php occ status
An unhandled exception has been thrown:
Doctrine\DBAL\Exception: Failed to connect to the database: An exception occurred in the driver: could not find driver in /var/www/nextcloud/lib/private/DB/Connection.php:139

Apache Seems to be up and running

root@behome:/var/www/nextcloud# sudo systemctl status apache2
● apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2023-02-09 01:13:21 UTC; 1h 12min ago

PHP Version is 8.1.2

root@behome:/var/www/nextcloud# php -v
PHP 8.1.2-1ubuntu2.10 (cli) (built: Jan 16 2023 15:19:49) (NTS)

MariaDB seems to be up and the account active

root@behome:/var/www/nextcloud# sudo mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 36
Server version: 10.6.11-MariaDB-0ubuntu0.22.04.1 Ubuntu 22.04
MariaDB [(none)]> SELECT host, user FROM mysql.user;
+-----------+-------------+
| Host      | User        |
+-----------+-------------+
| localhost | behome      |
| localhost | mariadb.sys |
| localhost | root        |
+-----------+-------------+
3 rows in set (0.002 sec)
root@behome:/var/www/nextcloud# mysql -u behome -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 41
Server version: 10.6.11-MariaDB-0ubuntu0.22.04.1 Ubuntu 22.04

The nextcloud database seems to be there:

MariaDB [(none)]> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| nextcloud          |
+--------------------+

I also don’t know if this matters, but… my nextcloud and nextcloud-data directories are in “/var/www”

root@behome:/var/www# dir
html  nextcloud  nextcloud-data

…not not “/var/www/html”

root@behome:/var/www/html# dir
index.html

OK - getting closer. Looks like not all the required PHP 8.1 packages were installed (ran the following… though I may have just needed mysql)

sudo apt-get install -y php8.1-cli php8.1-common php8.1-mysql php8.1-zip php8.1-gd php8.1-mbstring php8.1-curl php8.1-xml php8.1-bcmath

The full list of PHP modules installed are now:
behome@behome:~$ php -m
[PHP Modules]

bcmath
calendar
Core
ctype
curl
date
dom
exif
FFI
fileinfo
filter
ftp
gd
gettext
hash
iconv
igbinary
imagick
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
Phar
posix
readline
redis
Reflection
session
shmop
SimpleXML
sockets
sodium
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zip
zlib

occ status is no longer throwing a DB error,

behome@behome:/var/www/nextcloud$ sudo -u www-data php occ status                 
  - installed: true
  - version: 25.0.3.2
  - versionstring: 25.0.3
  - edition:
  - maintenance: false
  - needsDbUpgrade: false
  - productname: Nextcloud
  - extendedSupport: false

…but I’ve still got “Service Unavailable
The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.”

Tried:

  • apt install php8.1-apcu
  • add apc.enable_cli=1 to the bottom of /etc/php/8.1/cli/php.ini

source - Updated to 25.0.1.1 from 24. Error message: Service Unavailable

No change.

Get these in my /var/log/apache2/nextcloud.error about every 30 sec or so.

[Thu Feb 09 06:12:31.171072 2023] [proxy_fcgi:error] [pid 1537] [client 192.168.1.10:60245] AH01079: failed to make connection to backend: httpd-UDS
[Thu Feb 09 06:12:33.482561 2023] [proxy:error] [pid 1536] (2)No such file or directory: AH02454: FCGI: attempt to connect to Unix domain socket /run/php/php7.4-fpm.sock (*) failed

I only have PHP 8.1 installed

behome@behome:/var/log/apache2$ sudo update-alternatives --config php
There is only one alternative in link group php (providing /usr/bin/php): /usr/bin/php8.1

Any hints on which config file is still configured to 7.4?

Have you enabled the php8.1 mod in apache2?

It just might be that although you have 8.1 installed it isn’t being used

a2enmod and a2dismod should be your friends

check /etc/apache2/mods-enabled

Looks like it should be correct?

behome@behome:/etc/php/8.1/apache2$ a2dismod php7.4
Module php7.4 already disabled

behome@behome:/etc/php/8.1/apache2$ a2enmod php8.1
Considering dependency mpm_prefork for php8.1:
Considering conflict mpm_event for mpm_prefork:
Considering conflict mpm_worker for mpm_prefork:
Module mpm_prefork already enabled
Considering conflict php5 for php8.1:
Module php8.1 already enabled

Have a look here:

This is for different versions but it explains well enough how to switch modules and change php versions.

Thanks for the link - did all the various installs of PHP swapping back and forth (here I have 8.0 confugured)

behome@behome:/run$ sudo update-alternatives --config php
There are 7 choices for the alternative php (providing /usr/bin/php).

  Selection    Path             Priority   Status
------------------------------------------------------------
  0            /usr/bin/php8.1   81        auto mode
  1            /usr/bin/php5.6   56        manual mode
  2            /usr/bin/php7.0   70        manual mode
  3            /usr/bin/php7.1   71        manual mode
  4            /usr/bin/php7.2   72        manual mode
  5            /usr/bin/php7.3   73        manual mode
* 6            /usr/bin/php8.0   80        manual mode
  7            /usr/bin/php8.1   81        manual mode

…but it is still not working and the /var/log/appaci2/nextcloud.error is still showing

....attempt to connect to Unix domain socket /run/php/php7.4-fpm.sock (*) failed

looking at the /run directory there is no PHP sub folder

I see that php7.4 is located in an apache2 sub directory as follows (when disabled)

behome@behome:/run$ sudo find / -name php7.4
[sudo] password for behome:
/usr/share/bug/php7.4
/usr/share/doc/php7.4
/var/lib/apache2/module/disabled_by_admin/php7.4

and when enabled

behome@behome:/run$ sudo find / -name php7.4
/usr/share/bug/php7.4
/usr/share/doc/php7.4
/var/lib/apache2/module/enabled_by_admin/php7.4

anyone?

…or should I try a Apache reinstall?

Hello,

for this Error check the Config-File in /etc/apache2/sites-available (or /etc/apache2/sites-enabled) for your Nextcloud of apache2.

Check for (example):
<Proxy “unix:/var/run/php/php7.4-fpm-http.sock|fcgi://php-fpm-http”>

You have to change “php7.4-fpm” with “php8.1-fpm” and restart apache2.

Thanks - there was no reference to " :/var/run/php/php7.4-fpm -http.sock" or similar in any of the config files in either directory.

I did a search for “php7.4-fpm” and did find two entries in var/www/nextcloud/core/doc/admin/installation/nginx.html which I then changed to 8.1

Now my error log says
[proxy:error] [pid 76604] (2)No such file or directory: AH02454: FCGI: attempt to connect to Unix domain socket /run/php/php8.1-fpm.sock (*) failed

I not that this directory does not exist in /run

Okay. Did you use php-fpm for your Nextcloud in php7.4?

Please check the output of:
sudo service php8.1-fpm status

If you use php-fpm and there is no service for php8.1-fpm then install it with

sudo apt install php8.1-fpm
sudo service php8.1-fpm enable
sudo service php8.1-fpm start

and check the Nextcloud now…

Thanks - I’ve now given up and will retire this server.

You have never been able to figure out what caused the issue?

I have similar issue and as it as this is not the first time, I’m about to throw the towel.

Have you tried to stop and disable php7.4, remove all php7.4 packages. Install php8.1 with all your packages, then start and enable the service (php8.1-fpm.service) .

Make sure php7.4 mod is disabled and php8.1 is enabled in Apache2.

That should do it…

I had this issue as well, the fix for me in the end after making sure everything was installed correctly and the /run/php directory existed with .sock files was to make sure that in the /etc/php/8.1/fpm/pool.d/www.conf file the listen line stated the correct .sock file name. In my case it was php8.1-fpm.nextcloud.sock. after changing that and restarting php8.1-fpm.service the socket was created and everything started working again.

in order to get it to use php8.1-fpm.nextcloud.sock and not php7.4-fpm.nextcloud.sock I needed to edit the /etc/apache2/sites-enabled/ files and set the correct entry for the PHP sock.

After all that I also had realized part of my problem was the PHP8.1-fpm default config uses php8.1-fpm.sock and my nextcloud for some reason was configured with php8.1-fpm.nextcloud.sock. I’ve since removed the mention of ‘nextcloud’ from the php8.1-fpm.sock file name to prevent that issue for happening again in future updates.

2 Likes