Unable to start Nextcloud following 20.04 upgrade from 18.04

Hi –

I’m unable to get Nextcloud up and running following an upgrade from Ubuntu 18.04 to Ubuntu 20.04. Please note that everything worked as of a couple of hours ago, and had been flawlessly for months. A quick overview of the events leading up to my current issue:

  1. Upgrade Ubuntu 18.04 to 20.04. However, in this process, PHP, too, gets updated to version 7.4.xx, leading to: This version of Nextcloud is not compatible with > PHP 7.3.
  2. Not immediately able to fix this, I purge my system of php7.4* (as well as php7.3*, php8.* to catch anything lingering from my attempts of solving the above by downgrading PHP), and install php-7.3 from scratch.

Running php -v now shows PHP 7.3.28-2+ubuntu20.04.1+dev.sury.org+1, yet Nextcloud remains inaccessible.

  1. Unsure what to do, I ran sudo snap refresh nextcloud --channel=17. This installed and upgraded Nextcloud to revision 23903. Nextcloud remains inaccessible, but checking sudo systemctl | grep nextcloud shows:
  run-snapd-ns-nextcloud.mnt.mount                                                          loaded active     mounted   /run/snapd/ns/nextcloud.mnt                                                  
  snap-nextcloud-18204.mount                                                                loaded active     mounted   Mount unit for nextcloud, revision 18204                                     
  snap-nextcloud-23903.mount                                                                loaded active     mounted   Mount unit for nextcloud, revision 23903                                     
● snap.nextcloud.apache.service                                                             loaded failed     failed    Service for snap application nextcloud.apache                                
  snap.nextcloud.mdns-publisher.service                                                     loaded active     running   Service for snap application nextcloud.mdns-publisher                        
  snap.nextcloud.mysql.service                                                              loaded active     running   Service for snap application nextcloud.mysql                                 
  snap.nextcloud.nextcloud-cron.service                                                     loaded active     running   Service for snap application nextcloud.nextcloud-cron                        
  snap.nextcloud.nextcloud-fixer.service                                                    loaded active     running   Service for snap application nextcloud.nextcloud-fixer                       
  snap.nextcloud.php-fpm.service                                                            loaded active     running   Service for snap application nextcloud.php-fpm                               
  snap.nextcloud.redis-server.service                                                       loaded active     running   Service for snap application nextcloud.redis-server                          
  snap.nextcloud.renew-certs.service                                                        loaded active     running   Service for snap application nextcloud.renew-certs 

I assume this explains why I cannot access anything. However, checking sudo systemctl status snap.nextcloud.apache.service merely yields:

● snap.nextcloud.apache.service - Service for snap application nextcloud.apache
     Loaded: loaded (/etc/systemd/system/snap.nextcloud.apache.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Mon 2021-06-28 00:13:39 CEST; 28min ago
    Process: 21568 ExecStart=/usr/bin/snap run nextcloud.apache (code=exited, status=1/FAILURE)
   Main PID: 21568 (code=exited, status=1/FAILURE)

Jun 28 00:13:39 <computer> systemd[1]: snap.nextcloud.apache.service: Scheduled restart job, restart counter is at 5.
Jun 28 00:13:39 <computer> systemd[1]: Stopped Service for snap application nextcloud.apache.
Jun 28 00:13:39 <computer> systemd[1]: snap.nextcloud.apache.service: Start request repeated too quickly.
Jun 28 00:13:39 <computer> systemd[1]: snap.nextcloud.apache.service: Failed with result 'exit-code'.
Jun 28 00:13:39 <computer> systemd[1]: Failed to start Service for snap application nextcloud.apache.
  1. Not entirely sure what is going on, I attempted to further refresh Nextcloud seeing how versions 18, 19, and 20 should all be available. However, running sudo snap refresh nextcloud tells me that Nextcloud is up-to-date.

  2. I attempt to run php /var/www/nextcloud/index.php, but encounter PHP Fatal error: Uncaught Doctrine\\DBAL\\DBALException: Failed to connect to the database… realising that my purge in step 2 might have deleted MySQL, I install sudo apt install php7.3-mysql successfully.

  3. I can now run php /var/www/nextcloud/index.php without any errors, but I am still unabe to access my 192.168.x.y/nextcloud instance. At this time, I’ve already restarted the machine several times, but do so once more. The issue persists.

  4. Not convinced upgrading Nextcloud is really the way to go right now, I seek to restore my system to the state it was prior to upgrading to 20.04. I did this by running sudo snap revert nextcloud, allowing me to go back to revision 18204 with version 16.0.7snap2.

Attempting to access 192.168.x.y gives me the Apache2 screen.
Attempting to access 192.168.x.y/nextcloud gives me a blank screen, i.e. an internal server error.

  1. This suggests that a secondary Apache installation is running. I run sudo systemctl stop apache2 followed by a sudo snap restart nextcloud.

Attempting to access 192.168.x.y gives me the Apache2 screen.
Attempting to access 192.168.x.y/nextcloud yields a 404.

> sudo systemctl | grep apache2
  apache2.service                                                                           loaded active     running   The Apache HTTP Server                                                       
> sudo systemctl stop apache2
> sudo snap restart nextcloud
Restarted.
> sudo systemctl | grep nextcloud
  run-snapd-ns-nextcloud.mnt.mount                                                          loaded active     mounted   /run/snapd/ns/nextcloud.mnt                                                  
  snap-nextcloud-18204.mount                                                                loaded active     mounted   Mount unit for nextcloud, revision 18204                                     
  snap-nextcloud-23903.mount                                                                loaded active     mounted   Mount unit for nextcloud, revision 23903                                     
  snap.nextcloud.apache.service                                                             loaded active     running   Service for snap application nextcloud.apache                                
  snap.nextcloud.mdns-publisher.service                                                     loaded active     running   Service for snap application nextcloud.mdns-publisher                        
  snap.nextcloud.mysql.service                                                              loaded active     running   Service for snap application nextcloud.mysql                                 
  snap.nextcloud.nextcloud-cron.service                                                     loaded active     running   Service for snap application nextcloud.nextcloud-cron                        
  snap.nextcloud.nextcloud-fixer.service                                                    loaded active     running   Service for snap application nextcloud.nextcloud-fixer                       
  snap.nextcloud.php-fpm.service                                                            loaded active     running   Service for snap application nextcloud.php-fpm                               
  snap.nextcloud.redis-server.service                                                       loaded active     running   Service for snap application nextcloud.redis-server                          
  snap.nextcloud.renew-certs.service                                                        loaded active     running   Service for snap application nextcloud.renew-certs                           
> sudo systemctl | grep apache2

Seeing how the snap.nextcloud.apache.service is running now, it might have been a conflict with the other service, which no longer shows as currently running. Interestingly, attempting to access localhost yields the following:

nextclouderror

… so something is running, just not the instance I previously had running.

Running sudo nextcloud.occ shows the following:

Nextcloud is not installed - only a limited number of commands are available
Nextcloud 16.0.7

Usage:
  command [options] [arguments]

Options:
  -h, --help            Display this help message
  -q, --quiet           Do not output any message
  -V, --version         Display this application version
      --ansi            Force ANSI output
      --no-ansi         Disable ANSI output
  -n, --no-interaction  Do not ask any interactive question
      --no-warnings     Skip global warnings, show command output only
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Available commands:
  check                 check dependencies of the server environment
  help                  Displays help for a command
  list                  Lists commands
  status                show some status information
 app
  app:check-code        check code to be compliant
 integrity
  integrity:check-app   Check integrity of an app using a signature.
  integrity:check-core  Check integrity of core code using a signature.
  integrity:sign-app    Signs an app using a private key.
  integrity:sign-core   Sign core using a private key.
 l10n
  l10n:createjs         Create javascript translation files for a given app
 maintenance
  maintenance:install   install Nextcloud

…

It seems like I have somehow managed to stat the installation of Nextcloud instead of just returning to the one I was previously using. I have not edited anything in the config.php file, and have a copy of this elsewhere.

Any help moving forward would be greatly appreciated. This all worked prior to upgrading to Ubuntu 20.04. I suspect that the upgraded PHP, which caused the initial issue, and my handling of that, is the root cause.

Thanks!