How To Install Nextcloud On Debian 11 / Debian 10


Nextcloud is a self-hosted software suite that provides cloud storage over the network, and it is a fork of ownCloud. It is like a Google Drive / Dropbox that permits you to store, sync, and share your documents and pictures.

In this post, we will see how to install Nextcloud on Debian 11  / Debian 10.

Install Apache Web Server

First, install the Apache webserver for Nextcloud.

sudo apt update 
sudo apt install -y apache2 bzip2

Install MariaDB

Then, install the MariaDB database for Nextcloud installation. You can also use MySQL database in place of MariaDB.

sudo apt install -y mariadb-server mariadb-client

After the MariaDB installation, use the mysql_secure_installation command to secure MariaDB installation.

Install PHP 7.3 or 7.4

Nextcloud requires PHP version 7.3 or 7.4, and the same is available in the Debian OS repository. So you can use the apt command to install the PHP and its extensions for Nextcloud installation.

sudo apt install -y libapache2-mod-php php-gd php-json php-mysql php-curl php-mbstring php-intl php-imagick php-xml php-zip php-sqlite3

Once you have installed PHP, enable the following modules for Nextcloud.

sudo a2enmod rewrite
sudo a2enmod headers

Restart the Apache service.

sudo systemctl restart apache2

Install Nextcloud

Download Nextcloud

Nextcloud offers an archive package for Linux servers to download and manually set up on top of the LAMP stack.

cd /tmp/
tar -jxvf latest.tar.bz2
sudo mv nextcloud /var/www/html/
sudo mkdir /var/www/html/nextcloud/data

Update the ownership of the files inside the Nextcloud directory so that Apache users can write the data into it.

sudo chown -R www-data:www-data /var/www/html/nextcloud/

Create Database

Log in to the MariaDB server using the root user to create a database.

sudo mysql -u root -p

First, create a database called nextclouddb.

create database nextclouddb;

Then, grant nextclouduser to access the nextclouddb database on localhost with a password password.

grant all on nextclouddb.* to 'nextclouduser'@'localhost' identified by 'password';

Exit from the MariaDB shell.


Setup NextCloud

Open up your web browser and navigate it to the below URL.

  1. Fill up the username and password form to create an admin account.
  2. Then, click on Storage & Database.
  3. First, enter the location of Nextcloud’s data folder and then the database information in the Configure the database form of MySQL / MariaDB.
  4. After entering all the information, click Finish.

Access Nextcloud

After the installation is complete, the installer will take you to the home page of Nextcloud.

If the installer takes you to the non-existence page – https://index.php/core/apps/recommended, click the back button to go to Nextcloud.

Nextcloud Home Page
Nextcloud Home Page


That’s All. I hope you have learned how to install Nextcloud on Debian 11  / Debian 10. As a security measure, you can consider enabling HTTPS for your Nextcloud installation.

You might also like