Install and Configure Nextcloud on Debian 11

In this guide, we intend to teach you to Install and Configure Nextcloud on Debian 11.

Nextcloud is a collaboration platform, which enables organizations to share documents, send or receive emails, manage calendars, and communicate via secure video chats. Features include workflow automation, user authentication, compliance management, remote access, and audit tracking.

Steps To Install and Configure Nextcloud on Debian 11

To install Nextcloud, you must log in to your server as a non-root user with sudo privileges and set up a basic firewall. To do this, you can follow our guide the Initial Server Setup with Debian 11.

Also, you need to have LAMP Stack installed on your server. To do this, you can check How To Install LAMP Stack on Debian11.

Now follow the steps below to complete this guide.

Configure PHP for Nextcloud on Debian 11

At this point, you need to install some additional PHP extensions for Nextcloud on your server. To do this, run the command below:

# sudo apt -y install php-{cli,xml,zip,curl,gd,cgi,mysql,mbstring,fpm}

Then, you need to add the FPM support and restart your apache service:

# sudo a2enmod proxy_fcgi setenvif
# sudo a2enconf php7.4-fpm
# sudo systemctl restart apache2

Create a Nextcloud Database on Debian 11

At this point, you need to create a user and database for Nextcloud. First, log in to your MariaDB shell with the following command:

sudo mysql -u root -p

Then, from your MariaDB shell run the command below to create your user, here we named it nextcloud-user, remember to choose a strong password for it:

MariaDB [(none)]> CREATE USER 'nextcloud-user'@'localhost' IDENTIFIED BY "password";

Next, use the command below to create your database, here we named it nextclouddb:

MariaDB [(none)]> CREATE DATABASE nextclouddb;

Now you need to grant all the privileges to your Nextcloud DB with the command below:

MariaDB [(none)]> GRANT ALL PRIVILEGES ON nextclouddb.* TO 'nextcloud-user'@'localhost';

Flush the privileges and exit from your MariaDB shell with the commands below:

MariaDB [(none)]> exit;

Installing Nextcloud on Debian 11

At this point, you need to visit the Nextcloud official page and download it. Right-click on the Download for server from the Archive file and copy the link address.

Then, use the wget command to download Nextcloud on Debian 11:


Unzip your downloaded file with the command below:


Next, move your extracted file to the /var/www/html/ directory:

sudo mv nextcloud/ /var/www/html/

Now Set the correct ownership for your Nextcloud directory:

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

Create Apache Virtualhost file for Nextcloud on Debian 11

At this point, you need to create an Apache configuration file for NextCloud, to serve the file in case you are using the domain name or multiple websites are running on the same server.

Create and open your file with your favorite text editor, here we use vi:

sudo vi /etc/apache2/sites-available/nextcloud.conf

Add the following content to your file:

<VirtualHost *:80>
     DocumentRoot /var/www/html/nextcloud

     <Directory /var/www/html/nextcloud/>
          Options FollowSymlinks
          AllowOverride All
          Require all granted

     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined
     <Directory /var/www/html/nextcloud/>
            RewriteEngine on
            RewriteBase /
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteRule ^(.*) index.php [PT,L]

When you are done, save and close the file.

At this point, you need to disable the default Apache configuration and enable the new one you have created above:

# sudo a2dissite 000-default.conf
# sudo a2ensite nextcloud.conf

Also, enable a few modules:

sudo a2enmod headers rewrite env dir mime

Restart Apache, to apply the changes:

sudo systemctl restart apache2

Access Nextcloud Web Interface

When all the above steps are completed you are ready to access the web interface for setting up NextCloud further on your Debian 11.

Open your web browser and type your server’s IP address or domain name:


You will see the following screen. You need to create an Admin user and password and Then enter the details of the Database you have created. In the end, click Install.

Nextcloud login screen

Now the NextCloud Dashboard will be there to access and store your data.

Nextcloud dashboard

That’s it, you are done.


At this point, you learn to Install and Configure Nextcloud on Debian 11.

Hope you enjoy it.

You may be interested in these articles:

How To Install Ntopng on Debian 11

Set up Tesseract OCR on Debian 11

How To Install Wekan Server on Debian 11

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Stay informed and not overwhelmed, subscribe now!