How to install Nextcloud on Debian 12
Installing Nextcloud on Debian is easy to do and takes just a few steps. You’ll set up the actual cloud solution which is protected by various security mechanisms.
Nextcloud for Debian
Nextcloud is a recommended free cloud computing solution that provides plenty of options for both private and commercial use. Among the advantages of the software are strong security features for data protection, such as SSL/TLS encryption, two-factor authentication and GDPR compliance, as well as the choice between local private servers or outsourced host servers. Like many Nextcloud alternatives, the OwnCloud fork supports all common operating systems and offers easy integration of numerous services.
Here, we’ll explain how to set up Nextcloud on Debian 12 step by step. To do this, install an Apache2 web server, a MariaDB server and PHP 8.2. For security purposes, we’ll show you how to set up an Uncomplicated Firewall (UFW) and the required SSL/TLS certificates.
To install Nextcloud on Ubuntu, you can find the appropriate instructions for Nextcloud setup on Ubuntu 22.04 in our Digital Guide. Check out how to install Nextcloud on Docker here.
What requirements must be met?
There are just a few requirements to install Nextcloud on Debian 12. You need a server with Debian 12 installed. This requires at least 4 gigabytes of RAM and two CPUs. It’s also important that you have non-root user access with administrator rights and set up a domain name that can point to the server’s IP address.
Install Apache2 web server
First, install an Apache2 web server. To do this, update the Debian package index to download the latest version. You can use the command apt update for this:
Now, execute installation of the latest Apache2 package using the following command:
Confirm the installation with [y] and press [Enter] to initiate the installation.
After installation, check the status of the service using the following systemctl commands:
With the first command, you should see the service launch automatically when you boot the system. The status “active” indicates that Apache2 is ready for use.
Install Firewall
Protect your system and your data with a firewall. We recommend the Uncomplicated Firewall (UFW). To set it up as a default, open ports for OpenSSH, HTTP and HTTPS. Now, install the UFW package with the following command:
Confirm with [y] and complete the installation with [Enter]. Then activate OpenSSH and UFW with:
To start UFW, confirm with [y]. A message stating that firewall is active and enabled on system startup will now appear. Then add the HTTP and HTTPS ports for use by the web server. To do this, execute this command:
Load UFW again:
To view activated rules, launch the status of UFW. WWW Full should be activated here.
Activate PHP 8.2
For the best possible performance and maximum compatibility, Nextcloud recommends PHP 8.2. This is included by default in Debian 12, so you only need to install the necessary packages. The corresponding command is:
Confirm with [y] and [Enter]. Check the PHP version and activate the extensions:
Now launch the PHP configuration file with the nano editor:
You can now make changes and adapt the configuration to suit your needs. Depending on how you want to use Nextcloud on Debian 12, other values may be recommended. In this case, change the settings accordingly. The commands look like this.
Set up the time zone:
Amend the parameters for memory_limit, upload_max_filesize, post-max_size and max_execution_time:
Now activate file_uploads and allow_url_fopen. In both cases, the value should be set to “On”:
Deactivate display_errors and output_buffering and set the respective values to “Off”:
Activate PHP OPCache using the following command:
Paste the configuration in the opcache section recommended by Nextcloud for Debian 12:
Finally, save the file and exit the nano editor. Now restart the Apache2 service:
Set up MariaDB server
Nextcloud uses a MariaDB server as the database. Install it with this command:
Confirm with [y] and [Enter]. After successful installation, enter:
If the server is running smoothly, secure the system. Use the following command to create a root password, remove anonymous users and delete the test database:
Adjust settings by pressing [y] to accept and [n] to reject.
Create database and users
Now you can create a new database and the corresponding user. To log in to the MariaDB server, use the following command and enter your root password:
Use the following commands to create a new database, a user, and the corresponding password:
Replace “yourPassword” with a strong password of your choice. Finally, check whether “nextclouduser” can access the “nextcloud_db” database:
Download current source codes
Download the current source codes to be able to use Nextcloud on Debian 12:
Swap to the /var/www directory and download the latest source code:
Unzip the file and change the owner of the directory under www-data:
Configure Apache2 host
Now configure a virtual Apache2 host. Use this nano command:
Customize the domain name and the ErrorLog and CustomLog parameters. Replace the placeholder “example” with your domain name.
Save the changes and exit the editor. Then activate the configuration using the following command:
When you receive the output “Syntax OK”, restart Apache2 and apply the configuration of the host to it:
Security with SSL/TLS
You can now use Nextcloud on Debian 12 via an unsecured HTTP protocol. It’s recommended to set up HTTPS to protect your data. To do this, select:
Generate an SSL certificate by replacing the placeholder “example” with your domain name again:
Complete the Nextcloud on Debian 12 installation
You can now complete the installation of Nextcloud on Debian 12. To do this, open your web browser and enter the domain name of your Nextcloud installation. Enter a username and your password to create an administrator. Then enter the name of your database, the username and the password and hit “Install”. You may download some compatible apps or skip this for now. You’ll be redirected to your dashboard and can now use Nextcloud.