Command Line Uninstall of Nextcloud

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can. :heart:

The Basics

  • Nextcloud Server version (e.g., 29.x.x):
    • Not sure but I think it was 32.0.0 (current install not working)
  • Operating system and version (e.g., Ubuntu 24.04):
    • Ubuntu 24.04.3 LTS
  • Web server and version (e.g, Apache 2.4.25):
    • Apache 2
  • PHP version (e.g, 8.3):
    • 8.3.30
  • Installation method (e.g. AlO, NCP, Bare Metal/Archive, etc.)
    • Bare Metal: install on Ubuntu by command line i.e. Apache, the MySQL then Nextcloud
  • Are you using CloudfIare, mod_security, or similar? (Yes / No)
    • No

Summary of the issue you are facing:

How do I uninstall Nextcloud so I can reinstall it and hopefully solve my issue with it?

Apache seems to be working, my guess is MYSQL is working, so I’d like to reinstall Nextcloud hence my need to uninstall it. The following is how I installed it:

  1. Download and extract the files for Nextcloud:
    cd /var/www/
    wget https://download.nextcloud.com/server/releases/latest.tar.bz2
    tar -xvf latest.tar.bz2

  2. Create a data directory for your Nextcloud installation, ensure appropriate permissions are applied and edit the Nextcloud configuration files:
    mkdir -p /var/www/nextcloud/data
    chown -R www-data:www-data /var/www/nextcloud/
    chmod 750 /var/www/nextcloud/data

  3. To deal with the .htaccess file (allows configurations at the directory and subdirectory level) for Nextcloud, create a new configuration file for Apache:
    nano /etc/apache2/sites-available/nextcloud.conf

Paste the following into the empty file:
Alias /nextcloud “/var/www/nextcloud/”

DocumentRoot “/var/www/nextcloud”
# ServerName

ErrorLog ${APACHE_LOG_DIR}/nextcloud.error
CustomLog ${APACHE_LOG_DIR}/nextcloud.access combined

<Directory /var/www/nextcloud/>
Require all granted
AllowOverride All
Options FollowSymLinks MultiViews


Dav off

  1. Finally run these commands:
    a2ensite nextcloud.conf
    systemctl reload apache2 (or reboot)

NOTE: The file formatting above is not quite the same as my files :slight_smile:

If anyone can offer uninstallation advice, I’d appreciate it.

James

Pretty much the reverse of what you did.

Up to you decide whether any data (files and database content) matter to you.

The Admin Manual has bare metal installation mode backup/restore chapters.

There’s also an “uninstallation” chapter though I’d forgotten about it until you posted:

Simpler said than done. Despite 30 years in IT support, I’m an old git (retired) and I don’t really get Linux. Don’t get me wrong, I can use it, I can build it (I have a couple of Linux boxes right now inc. the Mini-PC I’m currently having issues which runs my NAS, media server and once ran Nextcloud) but I don’t really understand it. I document everything so I can rebuild it all but these things go wrong (the reason I’m asking these questions) and I just don’t know how to fix them.

In Windows, although there might be some leftovers or dependencies, I can typically just uninstall something, reinstall it and I’m away again and sure, that’s partially down to expertise/familiarity which is probably where I’m failing here.

I’ve looked at the link you provided and I’m pretty much left just scratching my head so, since I can’t find an easy way to uninstall, I’m probably gonna have to rebuild the entire server.

Anyway thanks for the link.

James

It also depends on your infrastructure (bare metal or VM-based) and whether you still need the data from the database.

If the database contents don’t really matter anymore and you mainly want to recover the files, you could simply set up a fresh instance and copy the files back. If you still need the database, you can of course back it up and restore it as well. However, if the database itself is causing the problems, that won’t necessarly help either. :wink:

As for the infrastructure side of things: if you’re running Nextcloud inside a VM, you could spin up a second VM with a fresh Nextcloud instance and migrate the data once everything is working properly.

Or you could take snapshots of the VM and actually try to understand what’s causing your issues and tackle them accordingly. If something goes wrong, you can simply revert within seconds. If you simply reinstall Nextcloud without understanding what caused the problems in the first place, and then use a similar configuration that may contain the same missing, misconfigured, or unoptimized settings, there’s a good chance you’ll just end up with the same issues again.

The third option would be to stop maintaining a full LAMP stack manually yourself and use Nextcloud AIO instead. That takes care of most of the configuration and maintenance work for you.

Doesn’t my first post (with the instructions I followed) pretty much imply it’s bare metal? No VMs involved.

I’m not worried about Nextcloud data as I carry out a full backup weekly.

Sounds like a possibility… I’ll check it out, thanks :+1:

James

Yeah, you’re right. I missed that.

But you could also take that as a hint to maybe consider using VMs. :wink: Obviously, it’s another thing you first need to become familiar with, but once you do, it comes with several advantages, snapshots being one of them.

Snapshots have saved my butt a few times when something went wrong during a Nextcloud update, OS update, database update, PHP update, etc.

:+1: