I had the same error. I was able to diagnose by:
- running
sudo -u www-data php -i
and noting that it was running php version 8.3 - I created a text file with
<?php phpinfo(); ?>
and saved it as “test.php” in /var/www/html sudo mv index.php index.php.bak
… this changes the default php script for nextcloud to have a different name.sudo cp test.php index.php
… this makes the test script created in #2 the main script for the nextcloud instance.- Opened the nextcloud instance in a web browser and noticed that it was reporting php 8.2
So I had a mismatch … the php was using 8.3 but apache2 was using 8.2.
To remedy this, I issued the following commands:
sudo apt install libapache2-mod-php8.3
- this ensures the php module you need is installedsudo a2enmod php8.3
- this enables apache2 to use php8.3sudo a2dismod php8.2
- this disables php8.2sudo systemctl restart apache2
- this restarts apache
(commands from How to install or upgrade to PHP 8.3 on Ubuntu and Debian • PHP.Watch)
After that was done, I restored the original index.php file in /var/www/html using sudo mv index.php.bak index.php
. Then nextcloud started right up.