Cannot fix Internal server error after upgrading PHP and then downgrading it again

Nextcloud version: 23.0.12

Operating system and version: Raspbian GNU/Linux 10 (buster) armv7l Linux 5.10.103-v7l+ #1529 SMP Tue Mar 8 12:24:00 GMT 2022 armv7l GNU/Linux

Apache version: 2.4.54

PHP version: 7.3

The issue I am facing:

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.

More details:

I was attempting to upgrade PHP to a newer version so that my instance could upgrade to a newer stable version. However, I accidentally upgraded to PHP 8.2, which is too high for any stable instance. However, everything appeared to work given the server merely said the version of PHP was too high. Therefore, I downgraded and tried to install PHP 7.4. When this failed spectacularly, I decided to give up and go back to a working Nextcloud 23 instance on PHP 7.3. However, I have not been able to resolve this issue. Interestingly, a standard phpinfo.php file will not load on my static site under /var/www/html. I am indeed using Apache, as well as Cloudflare (which is not affecting the error, since it is the same on my LAN)

Is this the first time you’ve seen this error? (Y/N): Y

Steps to replicate it:

  1. Visit the Nextcloud instance

Steps I have already taken to try and fix the error:

  1. Ensure the proper PHP packages are installed (including optional packages)
  2. Ensure the redis socket can be connected to
  3. Add extension=xxx to my php.ini file(s) (didn’t work, reverted)

The output of my Nextcloud log in Admin > Logging:

Unavailable

The output of my config.php file in /path/to/nextcloud:

<?php
$CONFIG = array (
  'instanceid' => 'oca5n1b35f4a',
  'passwordsalt' => 'REDACTED',
  'secret' => 'REDACTED',
  'trusted_domains' => 
  array (
    REDACTED
  ),
  'datadirectory' => '/home/pi/nextcloud',
  'dbtype' => 'mysql',
  'version' => '23.0.12.2',
  'overwriteprotocol' => 'https',
  'overwrite.cli.url' => 'http://192.168.1.217',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'REDACTED',
  'dbpassword' => 'REDACTED',
  'installed' => true,
  'has_rebuilt_cache' => true,
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'maintenance' => false,
  'app_install_overwrite' =>
  array (
    0 => 'files_external_gdrive',
    1 => 'breezedark',
    2 => 'spreed',
    3 => 'deck',
    4 => 'forms',
    5 => 'admin_notifications',
    6 => 'pdfdraw',
  ),
  'theme' => '',
  'loglevel' => 2,
  'mail_smtpsecure' => 'ssl',
  'mail_from_address' => 'nexus',
  'mail_domain' => 'jvadair.com',
  'mail_smtphost' => 'REDACTED,
  'mail_smtpport' => 'REDACTED',
  'mail_smtpauth' => 1,
  'mail_smtpname' => 'REDACTED',
  'mail_smtppassword' => 'REDACTED',
  'allow_local_remote_servers' => true,
  'memcache.local' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => 'localhost',
    'port' => 6379,
  ),

  'ncd_admin_settings' => 
  array (
    'disallow_aria2_settings' => '1',
  ),
);

The output of my Apache error log in /var/log/apache2/error.log (tail -n 7):

[Fri Jan 20 07:51:54.319803 2023] [mpm_prefork:notice] [pid 14954] AH00170: caught SIGWINCH, shutting down gracefully
PHP Warning:  PHP Startup: Unable to load dynamic library 'mysqlnd.so' (tried: /usr/lib/php/20190902/mysqlnd.so (/usr/lib/php/20190902/mysqlnd.so: cannot open shared object file: No such file or directory), /usr/lib/php/20190902/mysqlnd.so.so (/usr/lib/php/20190902/mysqlnd.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'mysqli.so' (tried: /usr/lib/php/20190902/mysqli.so (/usr/lib/php/20190902/mysqli.so: cannot open shared object file: No such file or directory), /usr/lib/php/20190902/mysqli.so.so (/usr/lib/php/20190902/mysqli.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'pdo_mysql.so' (tried: /usr/lib/php/20190902/pdo_mysql.so (/usr/lib/php/20190902/pdo_mysql.so: cannot open shared object file: No such file or directory), /usr/lib/php/20190902/pdo_mysql.so.so (/usr/lib/php/20190902/pdo_mysql.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'wddx.so' (tried: /usr/lib/php/20190902/wddx.so (/usr/lib/php/20190902/wddx.so: cannot open shared object file: No such file or directory), /usr/lib/php/20190902/wddx.so.so (/usr/lib/php/20190902/wddx.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
[Fri Jan 20 07:51:54.764702 2023] [mpm_prefork:notice] [pid 13652] AH00163: Apache/2.4.54 (Debian) OpenSSL/1.1.1n mod_wsgi/4.6.5 Python/2.7 configured -- resuming normal operations
[Fri Jan 20 07:51:54.764918 2023] [core:notice] [pid 13652] AH00094: Command line: '/usr/sbin/apache2'

The output of my Apache access log in /var/log/apache2/access.log (tail -n 10):

[Thu Jan 19 17:50:41.717151 2023] [core:notice] [pid 13831] AH00094: Command line: '/usr/sbin/apache2'
[Thu Jan 19 17:52:08.432849 2023] [mpm_prefork:notice] [pid 13831] AH00170: caught SIGWINCH, shutting down gracefully
PHP Warning:  PHP Startup: Unable to load dynamic library 'mysqlnd.so' (tried: /usr/lib/php/20190902/mysqlnd.so (/usr/lib/php/20190902/mysqlnd.so: cannot open shared object file: No such file or directory), /usr/lib/php/20190902/mysqlnd.so.so (/usr/lib/php/20190902/mysqlnd.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'mysqli.so' (tried: /usr/lib/php/20190902/mysqli.so (/usr/lib/php/20190902/mysqli.so: cannot open shared object file: No such file or directory), /usr/lib/php/20190902/mysqli.so.so (/usr/lib/php/20190902/mysqli.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'pdo_mysql.so' (tried: /usr/lib/php/20190902/pdo_mysql.so (/usr/lib/php/20190902/pdo_mysql.so: cannot open shared object file: No such file or directory), /usr/lib/php/20190902/pdo_mysql.so.so (/usr/lib/php/20190902/pdo_mysql.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'wddx.so' (tried: /usr/lib/php/20190902/wddx.so (/usr/lib/php/20190902/wddx.so: cannot open shared object file: No such file or directory), /usr/lib/php/20190902/wddx.so.so (/usr/lib/php/20190902/wddx.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
[Thu Jan 19 17:52:08.846023 2023] [mpm_prefork:notice] [pid 13913] AH00163: Apache/2.4.54 (Debian) OpenSSL/1.1.1n mod_wsgi/4.6.5 Python/2.7 configured -- resuming normal operations
[Thu Jan 19 17:52:08.846245 2023] [core:notice] [pid 13913] AH00094: Command line: '/usr/sbin/apache2'
[Thu Jan 19 17:52:35.731883 2023] [php7:error] [pid 13917] [client 172.71.254.125:57850] PHP Fatal error:  Uncaught Error: Call to undefined function \xc2\xa0\xc2\xa0phpinfo() in /var/www/html/phpinfo.php:2\nStack trace:\n#0 {main}\n  thrown in /var/www/html/phpinfo.php on line 2
[Thu Jan 19 17:55:44.057340 2023] [php7:error] [pid 13969] [client 162.158.103.146:9038] PHP Fatal error:  Uncaught Error: Call to undefined function \xc2\xa0\xc2\xa0phpinfo() in /var/www/html/phpinfo.php:2\nStack trace:\n#0 {main}\n  thrown in /var/www/html/phpinfo.php on line 2

Output errors in nextcloud.log in /var/www/ or as admin user in top right menu, filtering for errors.

Unavailable - nextcloud.log is not being written to

Please note that I have already put a fair amount of hours into researching and troubleshooting this error, and have already seen most of the forum posts here.

After carefully reviewing Apache’s error.log (not access.log), I noticed that some .so files related to MySQL were not available. To solve this problem, I ran sudo apt install --reinstall php7.3-mysql