Linux

How to Install Nextcloud: A Step-by-Step Guide for Ubuntu and Debian

How to Install Nextcloud: A Step-by-Step Guide for Ubuntu and Debian

Nextcloud is a powerful open-source software suite that allows you to host your own file storage and collaboration platform. It provides features such as file sharing, calendar synchronization, and collaborative editing, making it a perfect solution for personal and organizational use. In this guide, we’ll walk you through the installation of Nextcloud on Ubuntu and Debian systems.

Prerequisites
Before you start, ensure that you have:

A server running Ubuntu 20.04 or 22.04, or Debian 10 or 11.
Root or sudo access to the server.
A LAMP stack (Linux, Apache, MySQL/MariaDB, PHP) installed on your server. If you need help setting this up, refer to the official documentation or follow a guide to install LAMP on your system.
Recommended PHP Extensions
Nextcloud requires several PHP extensions to function correctly. You can install these with the following command:

sudo apt install php php-curl php-gd php-mbstring php-xml php-zip php-intl php-bcmath php-json php-gmp php-imagick

Step 1: Download Nextcloud
First, navigate to the Nextcloud download page to find the latest version:

wget https://download.nextcloud.com/server/releases/nextcloud-.zip

Replace with the latest version number.

After downloading, unzip the Nextcloud package:

unzip nextcloud-.zip

Move the Nextcloud directory to your web server’s root directory:

sudo mv nextcloud /var/www/

Step 2: Set Permissions
To ensure that the web server can access Nextcloud files, set the appropriate permissions:

sudo chown -R www-data:www-data /var/www/nextcloud
sudo chmod -R 755 /var/www/nextcloud

Step 3: Create a Database for Nextcloud
Next, create a database and a user for Nextcloud in your MySQL or MariaDB server.

Log in to your database server:

sudo mysql -u root -p

Create a new database and user:

CREATE DATABASE nextcloud;
CREATE USER ‘nextclouduser’@’localhost’ IDENTIFIED BY ‘yourpassword’;
GRANT ALL PRIVILEGES ON nextcloud.* TO ‘nextclouduser’@’localhost’;
FLUSH PRIVILEGES;
EXIT;

Replace yourpassword with a strong password.

Step 4: Configure Apache for Nextcloud
Create a new Apache configuration file for Nextcloud:

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

Add the following configuration:

ServerAdmin [email protected]
DocumentRoot /var/www/nextcloud
ServerName example.com
ServerAlias www.example.com

Options +FollowSymlinks
AllowOverride All

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

Replace example.com with your domain name.

Enable the new site and required Apache modules:

sudo a2ensite nextcloud.conf
sudo a2enmod rewrite headers env dir mime

Restart Apache to apply the changes:

sudo systemctl restart apache2

Step 5: Complete the Installation via Web Interface
Open your web browser and go to http://example.com (replace with your domain).

You should see the Nextcloud setup page. Here, enter the following:

Admin Account: Create a username and password for the Nextcloud admin account.
Data Folder: Leave the default path or specify a different one.
Database: Select MySQL/MariaDB as the database type and fill in the database details:
Database name: nextcloud
Username: nextclouduser
Password: yourpassword
Host: localhost
Click “Finish Setup.”

Step 6: Configure SSL (Optional but Recommended)
To secure your Nextcloud instance, it’s highly recommended to use HTTPS. You can obtain a free SSL certificate from Let’s Encrypt.

Install Certbot:

sudo apt install certbot python3-certbot-apache

Obtain an SSL certificate:

sudo certbot –apache

Follow the prompts to configure SSL for your domain.

Step 7: Configure Nextcloud Settings
Log in to your Nextcloud instance as the admin user.

Navigate to the settings page and configure options such as:

Data storage location
External storage support
User management

If you would like to improve yourself in server management, you can purchase a server from our site, experiment and improve yourself in an affordable and reliable environment. I wish you good luck.

Conclusion

Congratulations! You have successfully installed Nextcloud on your Ubuntu or Debian server. You can now enjoy the benefits of your own cloud storage solution, including file sharing, collaboration, and calendar integration. For more advanced features and configurations, consider exploring the Nextcloud documentation for further assistance.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button