Nextcloud

Nextcloud

Nextcloud is a self-hosted cloud storage platform that allows users to securely store, manage, and share files over the internet. Nextcloud is designed to give users full control over their data without relying on third-party cloud services. With features such as file synchronization, real-time document collaboration, calendars, contacts, and the ability to add additional applications, Nextcloud is ideal for individuals, organizations, and businesses looking to maintain the privacy of their data.

As an open-source solution, Nextcloud can be installed on private servers, VPS, or NAS devices and supports integration with various protocols such as WebDAV, CalDAV, and CardDAV. The main advantages of Nextcloud are its flexibility, security, and ability to meet modern collaboration needs without relinquishing data control to third parties.

1. System Requirements

The recommended system requirements for running Nextcloud v30 are as follows:

  • Operating System:
    • Ubuntu 22.04 LTS
    • Red Hat Enterprise Linux 9
  • Database:
    • MySQL 8.4
    • MariaDB 10.11
  • Web Server:
    • Apache 2.4 with mod_php or php-fpm
  • PHP Runtime:
    • PHP v8.3

Before starting the deployment, prepare the following:

  • A VPS or server with Ubuntu LTS installed
  • SSH access to the server
  • A domain already pointed to the server

2. Server Preparation

Update the system

sudo apt update
sudo apt upgrade -y

Install Apache

sudo apt install apache2 -y

Install MariaDB

sudo apt install mariadb-server -y

Install the ondrej/php PPA repository.

sudo add-apt-repository ppa:ondrej/php -y
sudo apt upgrade -y

Install PHP 8.3 and the required extensions.

sudo apt install libapache2-mod-php8.3 php8.3 php8.3-common \
    php8.3-cli php8.3-gd php8.3-xml php8.3-mbstring \
    php8.3-mysql php8.3-curl php8.3-zip php8.3-imagick zlib1g-dev -y

Open the php.ini configuration file.

sudo nano /etc/php/8.3/apache2/php.ini

Change the memory_limit value.

memory_limit = 512M

3. Create Database

Log in to MariaDB

sudo mysql

Create a database and user

CREATE DATABASE nextcloud;
CREATE USER 'nextcloud'@'localhost' IDENTIFIED BY 'rahasia';
GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextcloud'@'localhost';
FLUSH PRIVILEGES;
exit

4. Configure Apache

Create a virtual host configuration for cloud.contoh.com

sudo nano /etc/apache2/sites-available/cloud.contoh.com.conf	

Enter the configuration.

<VirtualHost *:80>
    ServerName cloud.contoh.com
    DocumentRoot /var/www/cloud.contoh.com
    <Directory /var/www/cloud.contoh.com>
        Options -Indexes +FollowSymLinks +MultiViews
        AllowOverride All
        Require all granted
    </Directory>
    ErrorLog /var/log/apache2/cloud.contoh.com_error.log
    CustomLog /var/log/apache2/cloud.contoh.com_access.log combined
</VirtualHost>

Enable the rewrite module, virtual host, and restart apache2.

sudo a2enmod rewrite
sudo a2ensite cloud.contoh.com
sudo systemctl restart apache2	

Install Certbot

sudo apt install certbot python3-certbot-apache -y	

Request an SSL certificate

sudo certbot --non-interactive \
    -m [email protected] \
    --agree-tos \
    --no-eff-email \
    --apache -d cloud.contoh.com \
    --redirect	

5. Install Nextcloud

Download the latest version of Nextcloud.

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

Extract nextcloud.zip.

sudo apt install unzip -y
sudo unzip nextcloud.zip

Move the extracted files to /var/www.

sudo mv nextcloud /var/www/cloud.contoh.com

Change the user-group to www-data.

sudo chown -R www-data:www-data /var/www/cloud.contoh.com

Access https://cloud.contoh.com to complete the Nextcloud installation.

  1. Enter the following:
    • Login: Username for the Nextcloud admin account
    • Password: Password for the Nextcloud admin account
    • Data folder: Data folder location, e.g., /var/www/cloud.contoh.com/data
    • Database account: Database username, e.g., nextcloud
    • Database password: Database password, e.g., rahasia
    • Database name: Database name, e.g., nextcloud
  2. Then click the Install button.
  3. Click Skip, and you will be redirected to the Dashboard.

The Nextcloud deployment is now complete and ready to use.