Introduction

Nextcloud is a widely used open source cloud storage software that allows users to store, share, and collaborate on their files, calendars, contacts, and more. In this tutorial, we will guide you through the step-by-step process of installing Nextcloud on your EndeavourOS system.

Prerequisites

Step 1: Update and Upgrade the System

Before installing any new package, it is usually recommended to update our system's package list and upgrade the installed packages to their latest version using the following command.

sudo pacman -Syu

Step 2: Install Required Dependencies

In order to install Nextcloud on your EndeavourOS system, we need to first install some required dependencies. These include PHP and its extensions, the web server, and the database server.

Installing PHP

By default, EndeavourOS comes with PHP 7.4. To install the required PHP extensions, run the following command.

sudo pacman -S php php-gd php-intl php-mbstring php-apcu php-zip

Installing Nginx (Optional)

If you prefer using Nginx as your web server, install it using the following command.

sudo pacman -S nginx

Installing Apache (Optional)

If you prefer using the Apache web server, install it using the following command.

sudo pacman -S apache

Installing MariaDB

Nextcloud requires either MariaDB or MySQL as a database server. To install MariaDB, run the following command.

sudo pacman -S mariadb

Step 3: Configure MariaDB

After installation, we need to configure MariaDB by setting up a root password, removing anonymous users, disabling remote root login, and removing the test database.

First, start the MariaDB service and enable it to start at boot time using the following command.

sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service

Next, run the following command to secure MariaDB:

sudo mysql_secure_installation

During the process, you will be prompted to set a root password, remove anonymous users, disable remote root login, and remove the test database.

Step 4: Creating Nextcloud Database

Log in to the MariaDB server using the root user and the password you set in the previous step.

sudo mysql -u root -p

Once logged in, create a new database and a user and grant them permissions to the database. Replace nextcloud_db, nextcloud_user, and password with your preferred database name, database user, and password.

CREATE DATABASE nextcloud_db;
GRANT ALL ON nextcloud_db.* TO 'nextcloud_user'@'localhost' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
EXIT;

Step 5: Download and Install Nextcloud

Next, we need to download and install Nextcloud. The latest version of Nextcloud can be found on their official website.

cd /var/www
sudo wget https://download.nextcloud.com/server/releases/latest.tar.bz2
sudo tar -jxf latest.tar.bz2
sudo chown -R http:http nextcloud
sudo rm latest.tar.bz2

Step 6: Configure Web Server

Next, we need to configure the web server.

Configuring Nginx (Optional)

If you are using Nginx as your web server, create a new server block with the following contents.

server {
        listen 80;
        server_name your_domain.com; # Replace with your domain name
        
        root /var/www/nextcloud/;
        index index.php;
        
        location / {
                try_files $uri $uri/ /index.php$request_uri;
        }
        
        location ~ ^/(?:\.htaccess|data|config|db_structure\.xml|README){
                deny all;
        }
        
        location ~ \.php(?:$|/) {
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/run/php-fpm/php-fpm.sock; # Change to your PHP-FPM socket
                fastcgi_index index.php;
                include fastcgi_params;
                fastcgi_param SCRIPT_FILENAME $request_filename;
                fastcgi_param PATH_INFO $fastcgi_path_info;
        }
}

Save the changes and restart the Nginx service.

sudo systemctl restart nginx.service

Configuring Apache (Optional)

If you are using Apache as your web server, create a new virtual host with the following contents.

<VirtualHost *:80>
        ServerName your_domain.com # Replace with your domain name
        DocumentRoot /var/www/nextcloud/
        <Directory /var/www/nextcloud/>
                Require all granted
                AllowOverride All
                Options FollowSymLinks MultiViews
                <IfModule mod_dav.c>
                        Dav off
                </IfModule>
        </Directory>
        
        ErrorLog /var/log/httpd/your_domain.com-error.log
        CustomLog /var/log/httpd/your_domain.com-access.log combined
        
        <IfModule mod_php.c>
                php_admin_flag engine on
        </IfModule>
</VirtualHost>

Save the changes and restart the Apache service.

sudo systemctl restart httpd.service

Step 7: Finish Installation

Finally, open your web browser and navigate to your domain name or IP address. Follow the on-screen instructions to complete the installation of Nextcloud. During the process, you will be asked to provide the database details we created in Step 4.

Congratulations! You have successfully installed Nextcloud on your EndeavourOS system.

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!

Alternatively, for the best virtual desktop, try Shells!