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 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(some servers require this) the repositories and upgrade the packages
sudo apt update && sudo apt upgrade -y.
Add a PPA to install PHP 8 maintained by a Debian maintainer.
sudo add-apt-repository ppa:ondrej/php -y
Update and upgrade:
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 versions for Apache with:
sudo a2dismod php7.3
Enable Apache PHP 8.0 module:
sudo a2enmod php8.0
You can also completely purge the older versions if you don’t need them.
sudo apt purge php7.3-common
sudo systemctl restart apache2