How to Install Nextcloud on Debian
In this tutorial, we will guide you through the process of installing Nextcloud on Debian latest version.
Step 1: Update and Upgrade Debian
Before we start with the installation, make sure your system is up-to-date with the latest packages. Open a terminal window and run the following commands:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
Enter your password when prompted and wait for the commands to finish.
Step 2: Install Required Packages
Nextcloud requires several packages to be installed on the system. Use the following command to install the packages:
sudo apt-get install apache2 mariadb-server libapache2-mod-php7.4 \
php7.4-gd php7.4-json php7.4-mysql php7.4-curl php7.4-mbstring \
php7.4-intl php7.4-imagick php7.4-xml php7.4-zip
Step 3: Configure MariaDB
Nextcloud requires a database to store its data. We will use MariaDB for this purpose. To configure MariaDB, run the following command:
sudo mysql_secure_installation
Follow the prompts to set a root password, remove anonymous users, disallow root login remotely, and remove the test database.
Next, we will create a new database and user for Nextcloud. Run the following commands to log into MariaDB and create a new database and user:
sudo mysql -u root -p
CREATE DATABASE nextcloud;
CREATE USER 'nextclouduser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextclouduser'@'localhost';
FLUSH PRIVILEGES;
exit;
Make sure to replace password with a strong password of your choice.
Step 4: Download Nextcloud
Download the Nextcloud package from the official website. You can accomplish this task by running the following command:
wget https://download.nextcloud.com/server/releases/nextcloud-22.1.1.tar.bz2
Extract the downloaded package by running the following command:
tar xjf nextcloud-22.1.1.tar.bz2
Copy the extracted files to your web server root directory by running the following command:
sudo cp -r nextcloud /var/www/html/
sudo chown -R www-data:www-data /var/www/html/nextcloud/
Step 5: Configure Apache
Next, we need to configure Apache to serve Nextcloud. We will create a new configuration file for Nextcloud. Run the following command to create the file:
sudo nano /etc/apache2/sites-available/nextcloud.conf
Add the following lines to the file:
<VirtualHost *:80>
ServerName example.com
Alias /nextcloud "/var/www/html/nextcloud/"
<Directory /var/www/html/nextcloud/>
Options +FollowSymlinks
AllowOverride All
Require all granted
<IfModule mod_dav.c>
Dav off
</IfModule>
SetEnv HOME /var/www/html/nextcloud
SetEnv HTTP_HOME /var/www/html/nextcloud
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Make sure to replace example.com with your own domain name or IP address.
Enable the new configuration file by running the following command:
sudo a2ensite nextcloud.conf
Reload Apache by running the following command:
sudo systemctl reload apache2
Step 6: Complete the Installation
Open a browser and navigate to http://example.com/nextcloud (replace example.com with your own domain name or IP address).
Nextcloud will prompt you to create an admin account and provide details about the database you created earlier. Fill in the details and click on the Finish setup button.
Congratulations, you have successfully installed Nextcloud on Debian!
Conclusion
In this tutorial, we guided you through the process of installing Nextcloud on Debian latest version. Now you can start using Nextcloud to store and share files securely.