Nextcloud Hub II or Nextcloud 23 dropped support for PHP 7.3. Instead of installing or sticking to PHP 7.4, it’s best to upgrade to PHP 8 on Ubuntu 20.04.
Note: Nextcloud (23) currently does not support PHP 8.1, so we will have to install and setup PHP 8.0.
In the default Ubuntu 20.04 repositories, the latest stable version you will find is PHP 7.4.
If you have just booted the server, you may need to update the repositories and upgrade the packages (some servers require this) using the command
sudo apt update && sudo apt upgrade -y.
Next add a PPA to install PHP 8.
sudo add-apt-repository ppa:ondrej/php -y
Update and upgrade the repositories.
sudo apt update && sudo apt upgrade -y
You can also install PHP 8.1 with just replacing the 0 with 1 in the command below.
Install the required packages:
sudo apt install libapache2-mod-php8.0 php8.0 php8.0-gmp php8.0-bcmath php8.0-gd php8.0-mysql php8.0-curl php8.0-mbstring php8.0-intl php8.0-imagick php8.0-xml php8.0-zip php8.0-fpm php8.0-redis php8.0-fileinfo php8.0-apcu
Disable older PHP version for Apache with:
sudo a2dismod php7.3
Enable Apache PHP 8.0 module:
sudo a2enmod php8.0
This is optional; you can set PHP 8.0 as your default version on the system. Please select from the available options.
update-alternatives --config php
You can also completely purge the older versions if you don’t need them.
sudo apt purge php7.3-common
sudo systemctl restart apache2