Nextcloud uses old PHP version

Nextcloud uses old PHP version

Nextcloud version: 25.0.4
Operating system and version: Ubuntu 22.04.2
Apache version: 2.4.52-1
PHP version: 8.1

The issue you are facing: I have installed PHP 8.1 and disabled PHP 7.4 by doing
a2dismod php7.4
a2enmod php8.1

Nextcloud still complains about the old PHP version used.

When I look at the processes, I see, that two php-fpm are running:
root 98103 1 0 13:16 ? 00:00:00 php-fpm: master process (/etc/php/8.1/fpm/php-fpm.conf)
root 102166 1 0 14:11 ? 00:00:00 php-fpm: master process (/etc/php/7.4/fpm/php-fpm.conf)

If I terminate the second one (7.4), Nextcloud is no longer accessible.

Is there any reference to check? I want to get rid of PHP 7.4 :wink:

Stop the service:
sudo systemctl stop php7.4-fpm.service

Also list
sudo dpkg -l |grep php7.4
and uninstall the packages if useful for you.

Normally you get with Ubuntu 22.04 LTS the correct packages and the old ones are uninstalled.

Ubuntu – Informationen ΓΌber Paket php in jammy
Ubuntu – Informationen ΓΌber Paket php in focal

You can also install the package apt-show-versions and list all packages from focal vs. jammy.

sudo apt-show-versions |grep -v jammy
(not tested)

Thank You for Your reply!

After stopping php7.4-fpm.service, the Nextcloud is no longer working (http error 403)

It seems, Nextcloud is still using PHP 7.4, but I don’t know why.

sudo stop php7.4-fpm
sudo a2disconf php7.4-fpm
sudo a2enconf php8.1-fpm
sudo systemctl restart apache2 && sudo systemctl restart php8.1-fpm

If it works:

sudo systemctl disable php7.4-fpm
2 Likes

Unfortunately it did not work. :frowning:
I get http error 503 in Nextcloud and nothing in nextcloud.log

Nextcloud still depends on php7.4-fpm.
When I enter sudo start php7.4-fpm, Nextcloud is working again

Is PHP8.1-FPM installed and is the service running?

Maybe more PHP8.1 packages are missing?

How exactly did you install and configure PHP the first time you installed Nextcloud? Did you use a specific tutorial and / or did you document your steps. Basically you should be able to install and configure PHP8.1 by taking the same steps, and just replacing the version number in your commands…

Yes, php8.1-fpm is running. See my first post.

I have installed php 8.1 with all the same modules like 7.4.

I have already updated around 10 Nextcloud installations the same way, but never had this problem before.

That’s what I did:

  1. Installed all the new php modules (here 8.1) which were present in the old php version (here 7.4).
  2. a2dismod php7.4
  3. a2enmod php8.1
  4. systemctl restart apache2

This always worked before… I really have no idea, what the differnce is here…

Unfortunately, I can’t think of anything specific from the top of my head. If you have access to one of the other servers, you can try to systematically compare all the relevant packages and configs. There has to be a difference somewhere…

Changing php Version procedure.

Install new php packages:

apt-get install php8.1-apcu php8.1-bcmath php8.1-bz2 php8.1-cli php8.1-common php8.1-curl php8.1-dev php8.1-fpm php8.1-gd php8.1-gmp php8.1-igbinary php8.1-imagick php8.1-intl php8.1-mbstring php8.1-mysql php8.1-opcache php8.1-phpdbg php8.1-readline php8.1-redis php8.1-xml php8.1-zip

This is wrong:

It must be:

a2disconf php7.4-fpm
a2enconf php8.1-fpm
systemctl reload apache2

Now you can go manually through all alternatives and look if are set to the new (8.1) versions: (phar, phar.phar, php, php-config, phpdbg, php-fpm.sock, phpize):

update-alternatives --all

Happy hacking.

php8.1-apcu is already the newest version (5.1.22+4.0.11-2+ubuntu22.04.1+deb.sury.org+1).
php8.1-bcmath is already the newest version (8.1.16+repack-1+ubuntu22.04.1+deb.sury.org+1).
php8.1-bz2 is already the newest version (8.1.16+repack-1+ubuntu22.04.1+deb.sury.org+1).
php8.1-cli is already the newest version (8.1.16+repack-1+ubuntu22.04.1+deb.sury.org+1).
php8.1-common is already the newest version (8.1.16+repack-1+ubuntu22.04.1+deb.sury.org+1).
php8.1-curl is already the newest version (8.1.16+repack-1+ubuntu22.04.1+deb.sury.org+1).
php8.1-dev is already the newest version (8.1.16+repack-1+ubuntu22.04.1+deb.sury.org+1).
php8.1-fpm is already the newest version (8.1.16+repack-1+ubuntu22.04.1+deb.sury.org+1).
php8.1-gd is already the newest version (8.1.16+repack-1+ubuntu22.04.1+deb.sury.org+1).
php8.1-gmp is already the newest version (8.1.16+repack-1+ubuntu22.04.1+deb.sury.org+1).
php8.1-igbinary is already the newest version (3.2.13-1+ubuntu22.04.1+deb.sury.org+1).
php8.1-imagick is already the newest version (3.7.0-3+ubuntu22.04.1+deb.sury.org+1).
php8.1-intl is already the newest version (8.1.16+repack-1+ubuntu22.04.1+deb.sury.org+1).
php8.1-mbstring is already the newest version (8.1.16+repack-1+ubuntu22.04.1+deb.sury.org+1).
php8.1-mysql is already the newest version (8.1.16+repack-1+ubuntu22.04.1+deb.sury.org+1).
php8.1-opcache is already the newest version (8.1.16+repack-1+ubuntu22.04.1+deb.sury.org+1).
php8.1-phpdbg is already the newest version (8.1.16+repack-1+ubuntu22.04.1+deb.sury.org+1).
php8.1-readline is already the newest version (8.1.16+repack-1+ubuntu22.04.1+deb.sury.org+1).
php8.1-redis is already the newest version (5.3.7+4.3.0-2+ubuntu22.04.1+deb.sury.org+1).
php8.1-xml is already the newest version (8.1.16+repack-1+ubuntu22.04.1+deb.sury.org+1).
php8.1-zip is already the newest version (8.1.16+repack-1+ubuntu22.04.1+deb.sury.org+1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

a2disconf php7.4-fpm
Conf php7.4-fpm already disabled
a2enconf php8.1-fpm
Conf php8.1-fpm already enabled

Also set everything to 8.1 with command update-alternatives --all

After stopping php7.4-fpm, Nextcloud ist down…

And after (or even better BEFORE) you did the upgrade to the new version, you should make the apropriate changes to:

/etc/php/8.1/cli/php.ini and /etc/php/8.1/fpm/php.ini:
; mandatory:
output_buffering = Off

; tuning, (these are my settings, change values to your needs):
max_execution_time = 3600
max_input_time = -1
memory_limit = 1G
post_max_size = 0
upload_max_filesize = 64G
max_file_uploads = 200
default_socket_timeout = 3600
opcache.enable=1
opcache.enable_cli=1
opcache.validate_timestamps=1
opcache.revalidate_freq=1

; optional:
include_path = β€œ.:/usr/bin/pear:/dev/urandom”

; If using redis:
redis.session.locking_enabled=1
redis.session.lock_retries=-1
redis.session.lock_wait_time=10000

Choose and configure how the process manager will control the number of child processes in this file:

/etc/php/8.1/fpm/pool.d/www.conf

Did you sudo systemctl reload apache2 ?

Yes, I did…

What does

sudo service php8.1-fpm status

say?

sudo service php8.1-fpm status
● php8.1-fpm.service - The PHP 8.1 FastCGI Process Manager
Loaded: loaded (/lib/systemd/system/php8.1-fpm.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2023-03-15 15:47:35 CET; 1h 51min ago
Docs: man:php-fpm8.1(8)
Process: 107488 ExecStartPost=/usr/lib/php/php-fpm-socket-helper install /run/php/php-fpm.sock /etc/php/8.1/fpm/pool.d/www.conf 81 (code=exited, status=0/SUCCESS)
Main PID: 107484 (php-fpm8.1)
Status: β€œProcesses active: 0, idle: 2, Requests: 0, slow: 0, Traffic: 0req/sec”
Tasks: 3 (limit: 9362)
Memory: 14.6M
CPU: 926ms
CGroup: /system.slice/php8.1-fpm.service
β”œβ”€107484 β€œphp-fpm: master process (/etc/php/8.1/fpm/php-fpm.conf)” β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€
β”œβ”€107486 β€œphp-fpm: pool www” β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€>
└─107487 β€œphp-fpm: pool www” β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€ β€œβ€>

Mar 15 15:47:35 nc-server1 systemd[1]: Starting The PHP 8.1 FastCGI Process Manager…
Mar 15 15:47:35 nc-server1 systemd[1]: Started The PHP 8.1 FastCGI Process Manager.

That looks normal.

What is the output of

ls -l "/etc/apache2/conf-enabled/"

lrwxrwxrwx 1 root root 30 Jul 9 2021 charset.conf β†’ …/conf-available/charset.conf
lrwxrwxrwx 1 root root 44 Jul 9 2021 localized-error-pages.conf β†’ …/conf-available/localized-error-pages.conf
lrwxrwxrwx 1 root root 46 Jul 9 2021 other-vhosts-access-log.conf β†’ …/conf-available/other-vhosts-access-log.conf
lrwxrwxrwx 1 root root 33 Mar 15 15:45 php8.1-fpm.conf β†’ …/conf-available/php8.1-fpm.conf
lrwxrwxrwx 1 root root 31 Jul 9 2021 security.conf β†’ …/conf-available/security.conf
lrwxrwxrwx 1 root root 36 Jul 9 2021 serve-cgi-bin.conf β†’ …/conf-available/serve-cgi-bin.conf

and

ls -l "/etc/apache2/mods-enabled/"

?

lrwxrwxrwx 1 root root 36 Jul 9 2021 access_compat.load β†’ …/mods-available/access_compat.load
lrwxrwxrwx 1 root root 28 Jul 9 2021 alias.conf β†’ …/mods-available/alias.conf
lrwxrwxrwx 1 root root 28 Jul 9 2021 alias.load β†’ …/mods-available/alias.load
lrwxrwxrwx 1 root root 33 Jul 9 2021 auth_basic.load β†’ …/mods-available/auth_basic.load
lrwxrwxrwx 1 root root 33 Jul 9 2021 authn_core.load β†’ …/mods-available/authn_core.load
lrwxrwxrwx 1 root root 33 Jul 9 2021 authn_file.load β†’ …/mods-available/authn_file.load
lrwxrwxrwx 1 root root 33 Jul 9 2021 authz_core.load β†’ …/mods-available/authz_core.load
lrwxrwxrwx 1 root root 33 Jul 9 2021 authz_host.load β†’ …/mods-available/authz_host.load
lrwxrwxrwx 1 root root 33 Jul 9 2021 authz_user.load β†’ …/mods-available/authz_user.load
lrwxrwxrwx 1 root root 32 Jul 9 2021 autoindex.conf β†’ …/mods-available/autoindex.conf
lrwxrwxrwx 1 root root 32 Jul 9 2021 autoindex.load β†’ …/mods-available/autoindex.load
lrwxrwxrwx 1 root root 30 Jul 9 2021 deflate.conf β†’ …/mods-available/deflate.conf
lrwxrwxrwx 1 root root 30 Jul 9 2021 deflate.load β†’ …/mods-available/deflate.load
lrwxrwxrwx 1 root root 26 Jul 9 2021 dir.conf β†’ …/mods-available/dir.conf
lrwxrwxrwx 1 root root 26 Jul 9 2021 dir.load β†’ …/mods-available/dir.load
lrwxrwxrwx 1 root root 26 Jul 9 2021 env.load β†’ …/mods-available/env.load
lrwxrwxrwx 1 root root 29 Jul 9 2021 filter.load β†’ …/mods-available/filter.load
lrwxrwxrwx 1 root root 30 Jul 9 2021 headers.load β†’ …/mods-available/headers.load
lrwxrwxrwx 1 root root 28 Jul 9 2021 http2.conf β†’ …/mods-available/http2.conf
lrwxrwxrwx 1 root root 28 Jul 9 2021 http2.load β†’ …/mods-available/http2.load
lrwxrwxrwx 1 root root 27 Jul 9 2021 mime.conf β†’ …/mods-available/mime.conf
lrwxrwxrwx 1 root root 27 Jul 9 2021 mime.load β†’ …/mods-available/mime.load
lrwxrwxrwx 1 root root 34 Mar 15 11:54 mpm_prefork.conf β†’ …/mods-available/mpm_prefork.conf
lrwxrwxrwx 1 root root 34 Mar 15 11:54 mpm_prefork.load β†’ …/mods-available/mpm_prefork.load
lrwxrwxrwx 1 root root 34 Jul 9 2021 negotiation.conf β†’ …/mods-available/negotiation.conf
lrwxrwxrwx 1 root root 34 Jul 9 2021 negotiation.load β†’ …/mods-available/negotiation.load
lrwxrwxrwx 1 root root 29 Mar 15 12:39 php8.1.conf β†’ …/mods-available/php8.1.conf
lrwxrwxrwx 1 root root 29 Mar 15 12:39 php8.1.load β†’ …/mods-available/php8.1.load
lrwxrwxrwx 1 root root 28 Jul 9 2021 proxy.conf β†’ …/mods-available/proxy.conf
lrwxrwxrwx 1 root root 33 Jul 9 2021 proxy_fcgi.load β†’ …/mods-available/proxy_fcgi.load
lrwxrwxrwx 1 root root 28 Jul 9 2021 proxy.load β†’ …/mods-available/proxy.load
lrwxrwxrwx 1 root root 33 Jul 9 2021 reqtimeout.conf β†’ …/mods-available/reqtimeout.conf
lrwxrwxrwx 1 root root 33 Jul 9 2021 reqtimeout.load β†’ …/mods-available/reqtimeout.load
lrwxrwxrwx 1 root root 30 Jul 9 2021 rewrite.load β†’ …/mods-available/rewrite.load
lrwxrwxrwx 1 root root 31 Jul 9 2021 setenvif.conf β†’ …/mods-available/setenvif.conf
lrwxrwxrwx 1 root root 31 Jul 9 2021 setenvif.load β†’ …/mods-available/setenvif.load
lrwxrwxrwx 1 root root 36 Jul 9 2021 socache_shmcb.load β†’ …/mods-available/socache_shmcb.load
lrwxrwxrwx 1 root root 26 Jul 9 2021 ssl.conf β†’ …/mods-available/ssl.conf
lrwxrwxrwx 1 root root 26 Jul 9 2021 ssl.load β†’ …/mods-available/ssl.load