This tutorial will show you how to install Nextcloud on Debian 12. Nextcloud is an open-source, user-friendly platform that empowers individuals and organizations to create their own private cloud services. With an emphasis on data privacy and self-hosting, Nextcloud offers a wide range of features, including file storage and synchronization, collaborative tools for document editing and sharing, and secure data storage options. Users can take control of their data by choosing to host Nextcloud on their own servers or rely on Nextcloud providers for hosting.
There are several steps to get Nextcloud up and running on our Debian 12 system. We will try to explain every step with some examples. I run my Debian 12 on Proxmox VE as a virtual machine. During the setup/installation process, there are no issues. It works very well. This will be a pretty long article but trust me, if you follow these steps carefully, you will be fine.
My Debian Server details:
- IP address: 192.168.100.11
- CPU: 2 Cores
- Memory 4 GB
- Disk: 20 GB
Steps to Install Nextcloud on Debian 12
- Update Debian
- Install Apache webserver
- Configure UFW(Firewall)
- Install PHP and extensions
- Install MariaDB and configure a new database for Nextcloud
- Download and Install Nextcloud
Step 1. Update Debian
First thing first, it is important to make sure our Debian 12 is up to date. Open the Terminal or connect via SSH to the Debian system. Then, run the update commands as root.
su apt update && apt upgrade
Step 2. Install Apache Web Server
Next, we are going to install Apache Web Server. Apache is the most popular web server application that has been used by millions of websites. To install Apache on Debian 12, follow these steps.
apt install apache2
Now let’s enable the Apache web server service
systemctl start apache2 systemctl enable apache2
Let’s check if our web server is up and running. Open a web browser from another computer and type the IP address of the server. You should see something like this shown on the browser.
Step 3. Install and Configure UFW (Firewall)
Once we have the Apache web server up and running, it is recommended to install UFW (Uncomplicated Firewall) and open ports for OpenSSH, HTTP, and HTTPS.
apt install ufw sudo ufw allow OpenSSH sudo ufw enable
Now, let’s enable the WWW Full profile for our web server that will allow access via HTTP and HTTPS protocols.
sudo ufw allow "WWW Full" sudo ufw reload
We can then check the ufw status with this command
sudo ufw status
Step 4. Install and Configure PHP
Now we need to install PHP and some other extensions that are needed by Nextcloud installation. Simply copy the following line and paste it into your Terminal.
sudo apt install -y php php-curl php-cli php-mysql php-gd php-common php-xml php-json php-intl php-pear php-imagick php-dev php-common php-mbstring php-zip php-soap php-bz2 php-bcmath php-gmp php-apcu libmagickcore-dev
Wait until the installation is completed. After that, we can check the PHP version and the installed extensions (modules) with this command.
php --version php -m
Once we have the PHP installed, we are now ready to configure it. We need to edit the php.ini file.
sudo nano /etc/php/8.2/apache2/php.ini
Configure the correct time zone. Uncomment the date.timezone line and change it to the correct time zone.
date.timezone = Asia/Jakarta
Next, change the default value for some parameters below.
memory_limit = 512M upload_max_filesize = 800M post_max_size = 500M max_execution_time = 300 zend_extension=opcache
And then, under the [opcache] section, add these lines which are recommended for Nextcloud installation
opcache.enable = 1
opcache.interned_strings_buffer = 8
opcache.max_accelerated_files = 10000
opcache.memory_consumption = 128
opcache.save_comments = 1
opcache.revalidate_freq = 1
Now save and close the editor and reload Apache
sudo systemctl restart apache2
Step 5. Install MariaDB and Create a New Database for Nextcloud
Now let’s install the MariaDB database server.
sudo apt install mariadb-server
Enable the service and check the status
sudo systemctl is-enabled mariadb sudo systemctl status mariadb
Make sure there is no error shown on the status
Secure the MariaDB installation
During this process, there are some questions that we need to take care of
- Press ENTER when asked for the MariaDB root password.
- Input n when asked about the unix_socket authentication method.
- Input Y to set up a new password for the MariaDB root user. Then, input the new password and repeat.
- Input Y to remove the default anonymous user from MariaDB.
- Then, input Y again to disable remote login for the MariaDB root user.
- Input Y to remove the default database test from MariaDB.
- Input Y again to reload table privileges and apply the changes.
Create New Database
Execute this command to login to MariaDB with root
sudo mariadb -u root -p
Now we will create a new database and user with the following configuration. You can change these as you need.
- database name: nextcloud_db
- user: nextcloud_user
- password: Str0ng.Password
CREATE DATABASE nextcloud_db; CREATE USER nextcloud_user@localhost IDENTIFIED BY 'Str0ng.Password'; GRANT ALL PRIVILEGES ON nextcloud_db.* TO nextcloud_user@localhost; FLUSH PRIVILEGES;
MariaDB [(none)]> CREATE DATABASE nextcloud_db; Query OK, 1 row affected (0.000 sec) MariaDB [(none)]> CREATE USER nextcloud_user@localhost IDENTIFIED BY 'Str0ng.Password'; Query OK, 0 rows affected (0.028 sec) MariaDB [(none)]> GRANT ALL PRIVILEGES ON nextcloud_db.* TO nextcloud_user@localhost; Query OK, 0 rows affected (0.025 sec) MariaDB [(none)]> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.000 sec)
At this point, we have successfully created a new database for our Nextcloud server.
Step 5. Download Nextcloud
Now we are ready to download and configure Nextcloud on Debian 12.
sudo apt install curl unzip -y cd /var/www/ curl -o nextcloud.zip https://download.nextcloud.com/server/releases/latest.zip
It will download the Nextcloud package called latest.zip and rename it to nextcloud.zip. Now we need to extract it and assign the proper permission to it.
unzip nextcloud.zip sudo chown -R www-data:www-data nextcloud
Now we have a new directory called nextcloud under /var/www/ directory. This is our nextcloud installation directory.
Configure Apache2 Virtual Host
We are about to configure the Apache2 virtual host needed by the Nextcloud. At this point, we need the IP address of our Debian server.
sudo nano /etc/apache2/sites-available/nextcloud.conf
And then, paste these lines
<VirtualHost *:80> ServerName 192.168.100.11 DocumentRoot /var/www/nextcloud/ # log files ErrorLog /var/log/apache2/nextcloud-io-error.log CustomLog /var/log/apache2/nextcloud-io-access.log combined <Directory /var/www/nextcloud/> Options +FollowSymlinks AllowOverride All <IfModule mod_dav.c> Dav off </IfModule> SetEnv HOME /var/www/nextcloud SetEnv HTTP_HOME /var/www/nextcloud </Directory> </VirtualHost>
Save and close the editor and run these two commands
sudo a2ensite nextcloud.conf sudo apachectl configtest
Finally, restart Apache
sudo systemctl restart apache2
Now open a web browser from the network and type the address as follows
Enter the new admin username and password. Also, we need to provide the database name, user, and password that we created earlier. Click Install to start the installation process. Once completes, we can enjoy Nextcloud