How to Install NextCloud on Debian 10

Install NextCloud on Debian 10

In this article, we will have explained the necessary steps to install up NextCloud on Debian 10. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

Nextcloud is an open-source file sharing and hosting solution. It is like a Google Drive / Dropbox that permits you to store documents, pictures, Videos, Movies, and any other media content in a centralized location. Desktop clients are available for most operating systems including, Windows, macOS, FreeBSD, and Linux.

Step 1. The first command will update the package lists to ensure you get the latest version and dependencies.

sudo apt update
sudo apt upgrade

Step 2. Install LAMP Stack on Debian Linux.

NextCloud is built with PHP. You can host it like you would any other web app is written in PHP. So, you’re going to need to set Debian up as either a LAMP server. If you haven’t done so already, use our traditional LAMP guide to set up Debian to serve PHP before you continue.

Step 3. Install NextCloud on the Debian system.

Now that we have our base LAMP stack set up, we can move on to installing Nextcloud itself. Use the commands in the following steps to download and install Nextcloud:

unzip nextcloud-*.zip

Next, copy the extracted folder into your web root directory:

sudo cp -r /home/user/Downloads/nextcloud /var/www/html/nextcloud

Change the owner and set the correct permissions for these files, you need to run the following command:

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

Step 4. Creating a MariaDB database for NextCloud.

NextCloud uses the MariaDB database to store all its data. Log in to your MariaDB server with the following command and enter your MariaDB root password:

mysql -u root -p

Once you’re in the MariaDB console, create a new database:

MariaDB > CREATE DATABASE nextcloud;
MariaDB > CREATE USER 'nextcloud'@'localhost' IDENTIFIED BY '[email protected]$d';
MariaDB > GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextcloud'@'localhost';
MariaDB > QUIT;

Step 4. Configuring Apache for NextCloud.

Next, you will need to create an Apache virtual host configuration file to serve NextCloud. You can create it with the following command:

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

Add the following lines:

<VirtualHost *:80>
     ServerAdmin [email protected]
     DocumentRoot /var/www/html/nextcloud

     Alias /nextcloud "/var/www/html/nextcloud/"

     <Directory /var/www/html/nextcloud/>
        Options +FollowSymlinks
        AllowOverride All
        Require all granted
          <IfModule mod_dav.c>
            Dav off
        SetEnv HOME /var/www/html/nextcloud
        SetEnv HTTP_HOME /var/www/html/nextcloud

     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined

Finally, restart the Apache services to apply the configuration changes:

sudo a2ensite nextcloud.conf
sudo a2enmod rewrite
sudo systemctl restart apache2

Step 5. Completing the NextCloud Installation.

Open your web browser and type the URL Here, you can create the admin user and configure database access. For the admin account, choose any secure username and password combination. For the database, enter the same credentials that you configured earlier.

That’s all you need to do to install NextCloud on Debian 10 Buster. I hope you find this quick tip helpful. For further reading on NextCloud, please refer to their official knowledge base. If you have questions or suggestions, feel free to leave a comment below.