Installing Nextcloud Correctly for Associations: Step-by-Step Guide to the Initial Installation on the Virtualmin Server

Learn how to install Nextcloud for your association on a Virtualmin server. From database selection to PHP settings to the initial security configuration—a comprehensive guide.

Introduction

Nextcloud is the ideal solution for associations to share files securely and collaborate. In this guide, we show you how to install Nextcloud on a Virtualmin server—from database selection to PHP settings to the initial security configuration. This way, you retain control over your data and can make your association work more efficient.

Prerequisites

Before you begin the installation, make sure the following prerequisites are met:

  • A virtual server with Virtualmin installed.
  • A domain pointing to your server.
  • SSH access and basic Linux knowledge.

Step 1: Create a Database for Nextcloud

Nextcloud requires a database. We recommend MariaDB or MySQL. You can create the database via the Virtualmin interface or via SSH.

Via Virtualmin:

  • Log in to Virtualmin and select your virtual server.
  • Go to "Edit Databases" and click "Create Database".
  • Select "MariaDB" or "MySQL" as the database type.
  • Specify a database name (e.g., nextcloud_db) and create a user with a secure password.

Via SSH:

mysql -u root -p
CREATE DATABASE nextcloud_db;
CREATE USER 'nextcloud_user'@'localhost' IDENTIFIED BY 'sicheresPasswort';
GRANT ALL PRIVILEGES ON nextcloud_db.* TO 'nextcloud_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Note down the database name, user, and password for later installation.

Step 2: Adjust PHP Settings

Nextcloud has specific requirements for PHP. Adjust the PHP configuration for your domain. In Virtualmin, you can find the PHP settings under "Server Configuration" > "PHP Options".

Set the following values:

  • memory_limit: 512M (recommended)
  • upload_max_filesize: 512M
  • post_max_size: 512M
  • max_execution_time: 300
  • max_input_time: 300
  • date.timezone: Europe/Berlin (or your timezone)

Additionally, you should enable the OPcache extension to improve performance. You can do this in the PHP settings under "PHP-FPM" or "PHP Options".

Step 3: Download and Extract Nextcloud

Download the latest Nextcloud version. You can do this via SSH:

cd /home/deinbenutzer/public_html
wget https://download.nextcloud.com/server/releases/latest.zip
unzip latest.zip
mv nextcloud/* .
rm -rf nextcloud latest.zip

Ensure that the files belong to the correct user (in Virtualmin, usually the domain user).

Step 4: Specify Storage Location for Data

By default, Nextcloud stores data in the data directory within the installation folder. For security reasons, you should place the data directory outside the web root. To do this, create a directory outside public_html, e.g., /home/deinbenutzer/nextcloud_data.

Set the permissions so that the web server user (e.g., www-data) can access it:

mkdir /home/deinbenutzer/nextcloud_data
chown www-data:www-data /home/deinbenutzer/nextcloud_data
chmod 750 /home/deinbenutzer/nextcloud_data

During the installation, you can then specify this path.

Step 5: Perform Nextcloud Installation

Now open your domain in the browser (e.g., https://deine-domain.de). The Nextcloud installer appears.

Fill in the fields:

  • Username and Password for the admin account.
  • Data folder: Enter the previously created path (e.g., /home/deinbenutzer/nextcloud_data).
  • Database: Select MySQL/MariaDB and enter the previously created credentials.

Click "Finish installation" and wait until the process is complete.

Step 6: Initial Security Configuration

After installation, you should make some security settings:

  • Enforce HTTPS: In Virtualmin, you can set up a Let's Encrypt certificate under "Server Configuration" > "SSL Settings" and enable "Redirect HTTP to HTTPS".
  • Check Nextcloud security warnings: Log in as admin and go to "Settings" > "Overview". Resolve any warnings displayed.
  • Block access to the data directory: Ensure that the data folder is not accessible via the web. This is already ensured by relocating it.
  • Set up backups: Set up regular backups, e.g., via Virtualmin or a script.
  • Two-factor authentication: Enable 2FA for admin accounts.

More tips can be found in our knowledge base.

Conclusion

With this guide, you have successfully installed Nextcloud on your Virtualmin server and implemented initial security measures. Your association can now benefit from a powerful and secure cloud solution. If you have any questions, our support is happy to help.