When will Nextcloud advice PHP 8.x for NC Installation above 22.x

At the moment the advice for every modern NC installation above 21.x is 7.x (7.3 and 7.4) is that still true?

It’s a while ago that i made a weighty mistake to switch from 7.4 to 8.0.x (under NC 21.x)
I am using some modules like

LDAP
Files access control
rainloop
client push
ONLYOFFICE
TOTP Provider

My logs filled with several errors - fatals - and warnings

Although NC is generally able to handle PHP 8 yours suggestion was to switch back to 7.x of PHP.
Is this advice still valid for the NC 22.2.x Versions?

PHP 8.0 and 8.1 are installed but 7.4.26 is enabled system wide for the moment.

If one has comparable modules in his / her NC installation and uses PHP 8.x it would be very kind to give your experiences here.

What i can say for the moment is, that switching the Database from postgresql@13-main to postgresql@14-main seems to work properly good with NC 22.2.3

Thanks a lot for your experiences …

You can change back to PHP 7.4 or 7.3 .

I always use the PHP version belongs to the linux distribution release.

Debian Buster: PHP 7.3
Debian Bullseye: PHP 7.4

Ubuntu 18.04 LTS: PHP 7.2
Ubuntu 20.04 LTS: PHP 7.4
(please use only LTS versions from Ubuntu)

I think Nextcloud supports ever this versions from the release.
You do not need PHP 8 at this time.

1 Like

There is a ticket in the bug tracker:

I am not sure if that covers all apps…

For future versions, they already discuss to drop php 7.3 support (Deprecation of php7.3 · Issue #29258 · nextcloud/server · GitHub) and adding php 8.1 support (Support PHP8.1 · Issue #29287 · nextcloud/server · GitHub). For the official recommendation, I don’t know if they refer to some sort of reference setup, and for the current version (22), it’s already the recommended one in the documentation: https://docs.nextcloud.com/server/latest/admin_manual/installation/system_requirements.html

Thanks for yours advices.

In April 2022 the new LTS 22.04 ubuntu will come with PHP 8.1 as far as some sites posted

So i will change my NC under ubuntu server 22.04 LTS when it’s on the wild.

From the github topic, it doesn’t look like you can expect full php 8.1 support from the beginning of the first release of NC 23. Rather NC 24. But you perhaps won’t upgrade ubuntu in the first days either. But planning to switch everything to the new Ubuntu 22 with php 8.1 next year sound like a good plan :+1:

I’m sorry, but NC 23.0.0. does noet support any PHP 8 version yet. You get a warning screen if you try that.
On our servers we have initialised support 7.3, 7.4, 8.0 and 8.1 for our users. We try to stay in line with supported versions of all server software.

8.0 should be supported, and for NC 23 it is even recommended:
https://docs.nextcloud.com/server/stable/admin_manual/installation/system_requirements.html

For php 8.1, please check the status and problems directly in the related bugtracker topic:

Keep in mind, that this only accounts for the main core code. It doesn’t mean that all the apps are already prepared. However it is good to test this, report and help to make all apps compatible with latest php versions. If possible, track down what part is creating the warning, so it can be reported and fixed.

I dont’t know what is the cause, but 8.0 does not work for me. I get:

Internal Server Error

The server encountered an internal error and was unable to complete your request.
Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.
More details can be found in the server log.

And in the server log is nothing to see.

The install matches latest, including RedHat Linux 8.

This is not mentioned in the ‘latest’ manual:

PHP8 does not support APCu anymore. When updating in this situation, the NC installation after updating hangs with a server error.
And yes, we are on PHP8.0 as recommended.

If you use Redis, replace in config.php:
‘memcache.local’ => ‘\OC\Memcache\APCu’,
with
‘memcache.local’ => ‘\OC\Memcache\redis’,

In my situation that worked. No caching error anymore.

But the warnings about opcache that is left, seem irrelevant. Even very high values in php.ini do not work. These values keep giving warnings:
opcache.interned_strings_buffer=32768
opcache.max_accelerated_files=150000

Where did you get that information from?

APCu is working well as it always did. Here starting from PHP 8.0.8 (that was when we switched from the PHP 7.4-series to the PHP 8.0-series and NC 22.1.1) and up to now with PHP 8.0.16:

NC’s config.php for APCu and Redis looks like:

  'memcache.local' => '\\OC\\Memcache\\APCu',
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'filelocking.enabled' => 'true',
  'redis' => 
  array (
    'host' => '127.0.0.1',
    'port' => 6379,
    'timeout' => 0,
    'password' => 'awesomepassword',
    'dbindex' => 0,
  ),

No errors regarding opcache whatsoever with the values:

opcache.interned_strings_buffer=8
opcache.max_accelerated_files=10000

All the above for:

  • Ubuntu 18.04.6 LTS
  • Apache 2.4.52 (using MPM Event)
  • PHP 8.0.16 (php-fpm active)
  • Redis 6.2.6
  • Nextcloud 22.2.5

on a production server with ~25 active users.

2 Likes

OK. I seem mis-informed by reading other blogs.
I will try this again, since this was my config.ini before that worked. Perhaps this will solve the opcache errors. Why this module is not in my PHP8.0? It was is 7.4 and before.

As you may have noticed I am usually installing certain packages manually.

For igbinary and APCu manual installation is trivial.

From CLI

igbinary:
sudo pecl install igbinary

APCu:
sudo pecl install apcu

Don’t forget to add the library path for igbinary and APCu to /etc/ld.so.conf and execute:
sudo /sbin/ldconfig

Now reload Apache/Ninx and check phpinfo.php.

Done.

I use PHP packages from Ondrej Sury maintainer of PHP in Debian. My configuartion is based on Carsten Rieger’s tutorial and I haven’t had any of the issues that keep popping up here in the forums…

Add the repositories:

sudo apt install software-properties-common ca-certificates lsb-release apt-transport-https curl wget

Debian:

sudo sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list' 
wget -qO - https://packages.sury.org/php/apt.gpg | sudo apt-key add - 

Ubuntu:

add-apt-repository -y ppa:ondrej/php

Install and configure PHP and Redis:

Click me

4. PHP-FPM and Redis-Server

4.1 Install packages and configure PHP

Install the required packages:

apt update -q4 && apt install -y redis-server libapache2-mod-php8.0 php8.0-{fpm,gd,mysql,curl,xml,zip,intl,mbstring,bz2,ldap,apcu,bcmath,gmp,imagick,igbinary,redis,smbclient,cli,common,opcache,readline,imagick,redis} imagemagick unzip

Backup all configuration files:

cp /etc/php/8.0/fpm/pool.d/www.conf /etc/php/8.0/fpm/pool.d/www.conf.bak
cp /etc/php/8.0/fpm/php-fpm.conf /etc/php/8.0/fpm/php-fpm.conf.bak
cp /etc/php/8.0/cli/php.ini /etc/php/8.0/cli/php.ini.bak
cp /etc/php/8.0/fpm/php.ini /etc/php/8.0/fpm/php.ini.bak
cp /etc/php/8.0/fpm/php-fpm.conf /etc/php/8.0/fpm/php-fpm.conf.bak
cp /etc/php/8.0/mods-available/apcu.ini /etc/php/8.0/mods-available/apcu.ini.bak
cp /etc/ImageMagick-6/policy.xml /etc/ImageMagick-6/policy.xml.bak

Set the time zone for the operating system:

To list all available time zones, you can either list the files in the /usr/share/zoneinfo directory or invoke the timedatectl command with the list-timezones option:

timedatectl set-timezone Europe/Zurich

Set the time zone for the PHP configuration:

A list with all supported time zones is available here: PHP: List of Supported Timezones - Manual

sed -i 's/;date.timezone.*/date.timezone = Europe\/\Zurich/' /etc/php/8.0/cli/php.ini
sed -i 's/;date.timezone.*/date.timezone = Europe\/\Zurich/' /etc/php/8.0/fpm/php.ini

Calaculate the PHP-FPM Tweaks:

AvailableRAM=$(awk '/MemAvailable/ {printf "%d", $2/1024}' /proc/meminfo)
AverageFPM=$(ps --no-headers -o 'rss,cmd' -C php-fpm8.0 | awk '{ sum+=$1 } END { printf ("%d\n", sum/NR/1024,"M") }')
FPMS=$((AvailableRAM/AverageFPM))
PMaxSS=$((FPMS*2/3))
PMinSS=$((PMaxSS/2))
PStartS=$(((PMaxSS+PMinSS)/2))

Add additional configuration parameters:

sed -i "s/;env\[HOSTNAME\] = /env[HOSTNAME] = /" /etc/php/8.0/fpm/pool.d/www.conf
sed -i "s/;env\[TMP\] = /env[TMP] = /" /etc/php/8.0/fpm/pool.d/www.conf
sed -i "s/;env\[TMPDIR\] = /env[TMPDIR] = /" /etc/php/8.0/fpm/pool.d/www.conf
sed -i "s/;env\[TEMP\] = /env[TEMP] = /" /etc/php/8.0/fpm/pool.d/www.conf
sed -i "s/;env\[PATH\] = /env[PATH] = /" /etc/php/8.0/fpm/pool.d/www.conf
sed -i 's/pm.max_children =.*/pm.max_children = '$FPMS'/' /etc/php/8.0/fpm/pool.d/www.conf
sed -i 's/pm.start_servers =.*/pm.start_servers = '$PStartS'/' /etc/php/8.0/fpm/pool.d/www.conf
sed -i 's/pm.min_spare_servers =.*/pm.min_spare_servers = '$PMinSS'/' /etc/php/8.0/fpm/pool.d/www.conf
sed -i 's/pm.max_spare_servers =.*/pm.max_spare_servers = '$PMaxSS'/' /etc/php/8.0/fpm/pool.d/www.conf
sed -i "s/;pm.max_requests =.*/pm.max_requests = 1000/" /etc/php/8.0/fpm/pool.d/www.conf
sed -i "s/allow_url_fopen =.*/allow_url_fopen = 1/" /etc/php/8.0/fpm/php.ini
sed -i "s/output_buffering =.*/output_buffering = 'Off'/" /etc/php/8.0/cli/php.ini
sed -i "s/max_execution_time =.*/max_execution_time = 3600/" /etc/php/8.0/cli/php.ini
sed -i "s/max_input_time =.*/max_input_time = 3600/" /etc/php/8.0/cli/php.ini
sed -i "s/post_max_size =.*/post_max_size = 10240M/" /etc/php/8.0/cli/php.ini
sed -i "s/upload_max_filesize =.*/upload_max_filesize = 10240M/" /etc/php/8.0/cli/php.ini
sed -i "s/memory_limit = 128M/memory_limit = 1024M/" /etc/php/8.0/fpm/php.ini
sed -i "s/output_buffering =.*/output_buffering = 'Off'/" /etc/php/8.0/fpm/php.ini
sed -i "s/max_execution_time =.*/max_execution_time = 3600/" /etc/php/8.0/fpm/php.ini
sed -i "s/max_input_time =.*/max_input_time = 3600/" /etc/php/8.0/fpm/php.ini
sed -i "s/post_max_size =.*/post_max_size = 10240M/" /etc/php/8.0/fpm/php.ini
sed -i "s/upload_max_filesize =.*/upload_max_filesize = 10240M/" /etc/php/8.0/fpm/php.ini
sed -i "s/;session.cookie_secure.*/session.cookie_secure = True/" /etc/php/8.0/fpm/php.ini
sed -i "s/;opcache.enable=.*/opcache.enable=1/" /etc/php/8.0/fpm/php.ini
sed -i "s/;opcache.enable_cli=.*/opcache.enable_cli=1/" /etc/php/8.0/fpm/php.ini
sed -i "s/;opcache.memory_consumption=.*/opcache.memory_consumption=128/" /etc/php/8.0/fpm/php.ini
sed -i "s/;opcache.interned_strings_buffer=.*/opcache.interned_strings_buffer=8/" /etc/php/8.0/fpm/php.ini
sed -i "s/;opcache.max_accelerated_files=.*/opcache.max_accelerated_files=10000/" /etc/php/8.0/fpm/php.ini
sed -i "s/;opcache.revalidate_freq=.*/opcache.revalidate_freq=1/" /etc/php/8.0/fpm/php.ini
sed -i "s/;opcache.save_comments=.*/opcache.save_comments=1/" /etc/php/8.0/fpm/php.ini
sed -i "s|;emergency_restart_threshold.*|emergency_restart_threshold = 10|g" /etc/php/8.0/fpm/php-fpm.conf
sed -i "s|;emergency_restart_interval.*|emergency_restart_interval = 1m|g" /etc/php/8.0/fpm/php-fpm.conf
sed -i "s|;process_control_timeout.*|process_control_timeout = 10|g" /etc/php/8.0/fpm/php-fpm.conf
sed -i '$aapc.enable_cli=1' /etc/php/8.0/mods-available/apcu.ini
sed -i "s/rights=\"none\" pattern=\"PS\"/rights=\"read|write\" pattern=\"PS\"/" /etc/ImageMagick-6/policy.xml
sed -i "s/rights=\"none\" pattern=\"EPS\"/rights=\"read|write\" pattern=\"EPS\"/" /etc/ImageMagick-6/policy.xml
sed -i "s/rights=\"none\" pattern=\"PDF\"/rights=\"read|write\" pattern=\"PDF\"/" /etc/ImageMagick-6/policy.xml
sed -i "s/rights=\"none\" pattern=\"XPS\"/rights=\"read|write\" pattern=\"XPS\"/" /etc/ImageMagick-6/policy.xml

Disable mpm_prefork, enable php-fpm with mpm_event and restart all relevant services:

systemctl restart php8.0-fpm
a2dismod php8.0 && a2dismod mpm_prefork
a2enmod proxy_fcgi setenvif mpm_event
systemctl restart apache2
a2enconf php8.0-fpm
systemctl restart apache2 && systemctl restart php8.0-fpm 

4.2 Configure Redis

Backup the Redis configuration file:

cp /etc/redis/redis.conf /etc/redis/redis.conf.bak

Adjust the configuration:

sed -i "s/port 6379/port 0/" /etc/redis/redis.conf
sed -i s/\#\ unixsocket/\unixsocket/g /etc/redis/redis.conf
sed -i "s/unixsocketperm 700/unixsocketperm 770/" /etc/redis/redis.conf
sed -i "s/# maxclients 10000/maxclients 512/" /etc/redis/redis.conf
usermod -aG redis www-data

Backup the file sysctl.conf:

cp /etc/sysctl.conf /etc/sysctl.conf.bak

Set avm.overcommit_memory to a value of 1:

sed -i '$avm.overcommit_memory = 1' /etc/sysctl.conf

4.3 Reboot your server!

Reboot your server:

reboot

There is a documentation: System Requirements Nextcloud

But i think for php:
**8.0** (*recommended*)
is not really good.

I think the advantage for small installs does not outweigh the hassle of not having a PHP version from the default sources on low linux knowledge.

Please: Use the default php version from your linux release. Thanks.

It’s not that big of a hassle. But sure you need to know how to manage package sources on your Linux distribution. Otherwise you’re right and it’s probably better to stay with the PHP version that ships with your distribution. But Debian 11 for example ships with PHP 7.4, and I doubt that this will still be a good choice with version 24, 25 or even 26 of Nextcloud, which are all likely to be released before the next Debian release :wink:

1 Like

Yes. And Ubuntu 22.04 LTS will be shipped with PHP 8.1. Hopefully Nextcloud 24 is shipped first.

1 Like

Normally, upgrades for Ubuntu LTS will not be actively rolled out until the first point release. That should give us a few extra months. But of course there will be enough people who won’t wait and will do a do-release-upgrade -d on day one. So April will certainly be an interesting and exciting month here in the forums… :wink:

1 Like

In my opinion, used components of LTS versions of distributions with large propagation should always be supported by Nextcloud and the phase out be kept in sync with them. I estimate the effort and complexity as relatively small, because straight LTS versions are itself particularly aligned to provide stability and continuity…

At least with Ubuntu LTS and RHEL this is the case, maybe not always for the full 5 years (Ubuntu) or even 10 years (RHEL) of every release. Especially the latter would be quite unrealistic if you want to use reasonably modern faetures. But the PHP versions in the latest Ubuntu LTS und RHEL releases were always supported and these are also the recommended OSs according to the documentation. System requirements — Nextcloud latest Administration Manual latest documentation

1 Like

Sure, 10 years is practically impossible. Besides, just as relevant as the operating systems are of course the life cycles of the middleware components: e.g. PHP 7.3 has not been maintained since Dec '21, EoL for 7.4 is Nov '22, this of course has to be respected by the NC release planning. I see already some prominent App that doesn’t support PHP <8.0 anymore - I don’t think this is a good practice in an ecosystem like Nextcloud…