Edited 8 months ago by ExtremeHow Editorial Team
DebianNextcloudCloud StorageServer SetupLinuxOpen SourceSystem AdministrationCLIFile SharingIT
This content is available in 7 different language
Nextcloud is a popular and powerful open-source software for creating your own cloud. It is useful if you want a personal cloud server to store, share, and sync data between your devices. In this guide, we will walk you through the process of setting up Nextcloud on a Debian server. This lesson will guide you step by step, from installing the necessary software to securely configuring your Nextcloud environment.
Before we begin, make sure you have the following prerequisites:
First, make sure your system is up-to-date. You can do this by doing this:
sudo apt update && sudo apt upgrade -y
This command updates the list of available packages and their versions and installs the latest versions of all currently installed packages.
Nextcloud requires a web server, PHP, and a database server. We will be using Apache, PHP, and MariaDB. Install these packages using the command:
sudo apt install apache2 mariadb-server libapache2-mod-php7.4
Next, we need to install the required PHP modules for Nextcloud:
sudo apt install php7.4-common php7.4-gmp php7.4-bcmath php7.4-curl php7.4-gd php7.4-mysql php7.4-intl php7.4-mbstring php7.4-xmlrpc php7.4-xml php7.4-zip php7.4-dom php7.4-imagick php7.4-soap php7.4-json php7.4-cli
Once the installation is complete, make sure Apache and MariaDB are running and set to run at startup:
sudo systemctl start apache2 sudo systemctl enable apache2 sudo systemctl start mariadb sudo systemctl enable mariadb
It is very important to keep your MariaDB installation secure. You can do this by running:
sudo mysql_secure_installation
This command will take you through a series of prompts to configure your database security settings such as setting the root password, removing anonymous users, disallowing root logins remotely, deleting the test database, and reloading privilege tables. Answer the prompts according to your needs.
Now, you need to create a database for Nextcloud. Log in to your MariaDB server:
sudo mysql -u root -p
After entering your password, create a new database and user by running the following:
CREATE DATABASE nextcloud; CREATE USER 'nextclouduser'@'localhost' IDENTIFIED BY 'securepassword'; GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextclouduser'@'localhost'; FLUSH PRIVILEGES; EXIT;
Replace 'securepassword' with a strong password of your choice.
We are ready to download the latest version of Nextcloud. Go to the /tmp directory and download Nextcloud:
cd /tmp wget https://download.nextcloud.com/server/releases/nextcloud-23.0.0.zip
Unzip the file and move it to the Apache web root:
unzip nextcloud-23.0.0.zip sudo mv nextcloud /var/www/html/
Set ownership of the Nextcloud directory to the Apache user:
sudo chown -R www-data:www-data /var/www/html/nextcloud/ sudo chmod -R 755 /var/www/html/nextcloud/
Now, create an Apache configuration file for Nextcloud:
sudo nano /etc/apache2/sites-available/nextcloud.conf
Paste the following configuration into the file:
<VirtualHost *:80> ServerAdmin admin@example.com DocumentRoot /var/www/html/nextcloud/ ServerName example.com ServerAlias www.example.com <Directory /var/www/html/nextcloud/> Options +FollowSymlinks AllowOverride All <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>
Save the file and exit the editor. Enable the site and any required Apache modules by running:
sudo a2ensite nextcloud.conf sudo a2enmod rewrite headers env dir mime
Finally, restart Apache to apply the changes:
sudo systemctl restart apache2
Make sure your firewall settings allow HTTP and HTTPS traffic. If you are using UFW, you can run the following:
sudo ufw allow 80/tcp sudo ufw allow 443/tcp sudo ufw reload
Now, open your web browser and visit the IP address or domain name of your Nextcloud server. You will be presented with a web page to finalize the setup:
To encrypt your Nextcloud installation, you can set up a free SSL certificate using Certbot and Let's Encrypt. Install Certbot by running the following:
sudo apt install certbot python3-certbot-apache
Obtain and install an SSL certificate:
sudo certbot --apache
Follow the prompts to authorize Certbot to issue certificates for your domain. Certbot will automatically configure your Apache with the new certificate.
You have successfully set up Nextcloud on your Debian server and configured it with a secure SSL connection. Once your cloud server is ready, you can start uploading files, sharing them, and syncing them securely across your devices. Remember to update your Nextcloud installation and system packages periodically for new features and security enhancements.
If you find anything wrong with the article content, you can