Nextcloud is a popular open-source cloud platform that allows you to store, sync, and share your files, contacts, calendars, and more. In this blog post, I will show you how to install Nextcloud on Linux using the official Nextcloud .tar archive. This method is recommended for installing Nextcloud, as it gives you more control and flexibility over your installation.

Before we begin, you will need the following prerequisites:

  • A Linux server running Ubuntu 18.04 LTS or later, with root or sudo access.
  • A web server such as Apache or Nginx, with PHP 7.4 or later and the required PHP modules. See PHP Modules & Configuration for a list of required and suggested modules.
  • A database server such as MySQL/MariaDB, PostgreSQL, or SQLite, with a database and a user created for Nextcloud.
  • A domain name pointing to your server’s IP address, and a TLS certificate from Let’s Encrypt or another provider.

Step 1: Download and extract the Nextcloud .tar archive

First, you need to download the latest version of Nextcloud from the official website. You can use the wget command to download the file to your server:

wget https://download.nextcloud.com/server/releases/nextcloud-28.0.0.tar.bz2

Next, you need to extract the file to your web server’s document root, which is usually /var/www/html for Apache or /usr/share/nginx/html for Nginx. You can use the tar command to extract the file:

tar xjf nextcloud-28.0.0.tar.bz2 -C /var/www/html

This will create a folder called nextcloud in your document root, containing all the files and folders of Nextcloud.

Step 2: Set the ownership and permissions of the Nextcloud folder

Next, you need to set the ownership and permissions of the Nextcloud folder, so that your web server can access and write to it. You can use the chown and chmod commands to do this:

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

The www-data user and group are the default ones for Apache and Nginx on Ubuntu, but you may need to change them according to your web server configuration.

Step 3: Configure your web server for Nextcloud

Next, you need to configure your web server to serve Nextcloud. You can use a virtual host or a server block to do this, depending on your web server. Here is an example of a virtual host for Apache:

<VirtualHost *:80>
    ServerName nextcloud.example.com
    DocumentRoot /var/www/html/nextcloud

    <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}/nextcloud.error.log
    CustomLog ${APACHE_LOG_DIR}/nextcloud.access.log combined
</VirtualHost>

And here is an example of a server block for Nginx:

server {
    listen 80;
    server_name nextcloud.example.com;
    root /usr/share/nginx/html/nextcloud;

    location / {
        try_files $uri $uri/ /index.php$request_uri;
    }

    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
    }

    location ~ /\.ht {
        deny all;
    }

    error_log /var/log/nginx/nextcloud.error.log;
    access_log /var/log/nginx/nextcloud.access.log;
}

You will need to replace nextcloud.example.com with your own domain name, and adjust the paths and parameters according to your web server and PHP configuration. You will also need to enable and reload your web server after making the changes.

Step 4: Enable HTTPS for Nextcloud

Next, you need to enable HTTPS for Nextcloud, to encrypt the communication between your server and your clients. You can use Let’s Encrypt to obtain a free and valid TLS certificate for your domain name. You can use the certbot tool to do this, which will also automatically configure your web server for HTTPS. You can install certbot from the official PPA:

sudo add-apt-repository ppa:certbot/certbot
sudo apt update
sudo apt install certbot

Then, you can run certbot with the web server plugin of your choice, such as --apache or --nginx, and follow the instructions:

sudo certbot --apache -d nextcloud.example.com

or

sudo certbot --nginx -d nextcloud.example.com

This will obtain and install the certificate, and redirect all HTTP requests to HTTPS. You can also enable automatic renewal of the certificate by adding a cron job or a systemd timer.

Step 5: Complete the Nextcloud installation wizard

Finally, you can complete the Nextcloud installation wizard by visiting your domain name in your web browser. You will see a screen like this:

 

Here, you need to enter the following information:

  • An admin username and password for your Nextcloud instance.
  • The database type, name, user, and password for your Nextcloud instance. You can choose between MySQL/MariaDB, PostgreSQL, or SQLite. If you choose MySQL/MariaDB or PostgreSQL, you will also need to enter the database host, which is usually localhost.
  • The data folder for your Nextcloud instance, which is where your files will be stored. You can leave it as the default /var/www/html/nextcloud/data, or change it to another location of your choice.

After entering the information, click on the Finish setup button to complete the installation. You will be redirected to the Nextcloud dashboard, where you can start using your cloud platform.

Congratulations, you have successfully installed Nextcloud on Linux! You can now explore the features and settings of Nextcloud, such as adding users, enabling apps, configuring security, and more. You can also download and install the Nextcloud desktop and mobile clients to sync your files across your devices. For more information and documentation, you can visit the Nextcloud website and the Nextcloud forum. I hope you enjoyed this blog post, and feel free to leave your comments and feedback below. Thank you for reading!



Wednesday, February 14, 2024

« Back