ServerGigabit Network

9 Easy Steps to Install Nextcloud on Debian 11 with Apache

You are here:
Estimated reading time: 3 min

Nextcloud

A powerful server environment is an excellent solution for running Nextcloud, a widely used open-source platform for file storage, collaboration, and productivity. It allows users to host their own private cloud instead of relying on third-party services. With proper configuration, it can provide reliable performance for businesses, developers, and personal users who require secure data management.

This guide explains how to install and configure the platform on a Debian 11 server using Apache2 as the web server. By following the steps below, you will be able to deploy a fully functional cloud storage system with database support and SSL security.

Before starting the installation, make sure your system packages are updated. Log in to your server as root and run the following command:

apt update && apt upgrade –y

 

Updating ensures that all packages are running the latest stable versions and reduces potential compatibility issues during installation.

Step 1: Install Required Packages

The first step is installing the essential software required for the environment. This includes Apache, database software, and several utility tools.

Run the following command:

apt install apache2 unzip wget curl mariadb-client mariadb-server nano

 

These packages provide the basic infrastructure needed for running a web-based cloud platform. Apache will handle web requests while MariaDB will manage the database that stores user data and configuration.

Step 2: Install PHP 8.0

Since the platform is built using PHP, you must install PHP and several required modules.

2A: Add the PHP Repository

First, add the trusted PHP repository:

apt-get install ca-certificates apt-transport-https software-properties-common -y
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/sury-php.list
apt install gnupg gnupg2 gnupg1 -y
wget -qO - https://packages.sury.org/php/apt.gpg | apt-key add -
apt update && apt upgrade -y
This repository provides newer PHP versions that are compatible with modern applications.

2B: Install PHP and Required Modules

Install PHP together with its important extensions:

apt install php8.0 -y
apt install libapache2-mod-php8.0 php8.0-{zip,xml,mbstring,gd,curl,imagick,intl,bcmath,gmp,cli,mysql,apcu,redis}

These modules enable additional features such as database connectivity, caching, file compression, and image processing.

2C: Configure PHP Settings

Next, edit the configuration file:

nano /etc/php/8.0/apache2/php.ini

Adjust the following values according to your system requirements:

  • memory_limit

  • upload_max_filesize

  • post_max_size

  • date.timezone

Increasing these limits is helpful when users upload large files.

Step 3: Create the Database

Next, create a database for storing application data.

Access MariaDB:

mysql –u root –p

Then run these commands:

CREATE DATABASE nextcloud;
CREATE USER 'nextcloud'@'localhost' IDENTIFIED BY 'PASSWORD';
GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextcloud'@'localhost';
FLUSH PRIVILEGES;
exit;

This creates a dedicated database and user account for the platform.

Step 4: Download the Application Files

Download the latest release directly from the official repository.

cd /tmp && wget https://download.nextcloud.com/server/releases/latest.zip
unzip latest.zip
rm latest.zip
mv nextcloud /var/www

This places the application files inside the web directory so Apache can access them.

Step 5: Configure Apache

Enable necessary Apache modules to support the web application.

Enable Modules

a2enmod rewrite headers env dir mime

Create a Virtual Host

Create a new configuration file:

nano /etc/apache2/sites-available/nextcloud.conf

Insert the required VirtualHost configuration and update it with your domain name.

After saving the file, activate the configuration:

a2ensite nextcloud.conf
systemctl restart apache2

Step 6: Create Optional Data Directory

If you prefer storing uploaded files in a different location, create a dedicated data directory.

mkdir /home/data

Separating the storage directory can improve organization and simplify backups.

Step 7: Permission Adjustments

Correct permissions are necessary for the web server to access the files.

chown -R www-data:www-data /var/www/nextcloud
chmod -R 755 /var/www/nextcloud
chown –R www-data:www-data /home/data # Adjust if using a different location

This ensures Apache can read and write the required directories.

Step 8: Install SSL Certificate

To secure user connections, install an SSL certificate using Certbot.

apt install certbot python3-certbot-apache -y
certbot --apache

Follow the prompts and select your domain name. After completion, HTTPS will automatically be configured.

Step 9: Complete Installation via Browser

Open your domain in a web browser to finish the setup.

During the installation process:

  1. Create an administrator account

  2. Choose the data folder location (optional)

  3. Enter database information:

    • Database User: nextcloud

    • Database Password: PASSWORD

    • Database Name: nextcloud

Click Install and wait for the setup to complete.

Once finished, the dashboard will appear and the private cloud system will be ready for use.

If you need step-by-step guidance on setting up Nextcloud, you can visit here.

Was this article helpful?
Dislike 0
Views: 28