How to Install Nextcloud on Ubuntu 24.04 VPS with Docker Compose

Introduction

At ByteHosting, we understand the importance of having a reliable and easy-to-manage cloud storage solution. Nextcloud is an excellent open-source platform that allows you to host your own private cloud, giving you control over your data. In this guide, we will walk you through the process of installing Nextcloud on Ubuntu 24.04 VPS using Docker Compose. This method is beginner-friendly and simplifies updates and management, making it ideal for those new to server administration.

Prerequisites: Setting up Your Ubuntu 24.04 VPS

Before we begin, ensure you have a fresh Ubuntu 24.04 VPS. If you haven't already, you can easily deploy one of our cost-effective VPS plans in Frankfurt, Germany, with instant delivery. You will need root or sudo access to install necessary packages and configure your server.

Installing Docker and Docker Compose on Ubuntu

Step 1: Update Your System

Start by updating your package list and upgrading existing packages:

sudo apt update && sudo apt upgrade -y

Step 2: Install Docker

Next, install Docker using the official convenience script:

curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh

Verify Docker installation:

docker --version

Step 3: Install Docker Compose

Download the latest Docker Compose binary:

sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

Make it executable:

sudo chmod +x /usr/local/bin/docker-compose

Check the installation:

docker-compose --version

Downloading and Configuring Nextcloud with Docker Compose

Step 1: Create a Directory for Your Nextcloud Setup

Organize your files by creating a dedicated directory:

mkdir ~/nextcloud-docker
cd ~/nextcloud-docker

Step 2: Create a Docker Compose File

Use your preferred text editor to create a docker-compose.yml file:

nano docker-compose.yml

Insert the following configuration, which sets up Nextcloud with a MariaDB database:

version: '3.7'

services:
  db:
    image: mariadb:10.5
    container_name: nextcloud-db
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: your_root_password
      MYSQL_PASSWORD: your_nextcloud_password
      MYSQL_DATABASE: nextcloud
      MYSQL_USER: nextcloud
    volumes:
      - db_data:/var/lib/mysql

  app:
    image: nextcloud:latest
    container_name: nextcloud-app
    restart: always
    ports:
      - "8080:80"
    environment:
      MYSQL_PASSWORD: your_nextcloud_password
      MYSQL_DATABASE: nextcloud
      MYSQL_USER: nextcloud
      MYSQL_HOST: db
    volumes:
      - nextcloud_data:/var/www/html
    depends_on:
      - db

volumes:
  db_data:
  nextcloud_data:

Replace your_root_password and your_nextcloud_password with strong passwords.

Step 3: Launch Nextcloud

Start your containers with:

docker-compose up -d

This command downloads the images and runs your Nextcloud instance in detached mode.

Starting Nextcloud and Accessing the Web Interface

Once the containers are running, open your browser and navigate to http://your_server_ip:8080. You should see the Nextcloud setup page. Complete the setup by entering your database details and creating an admin account.

Securing Nextcloud with SSL and User Authentication

Step 1: Obtain an SSL Certificate

For security, it's essential to enable HTTPS. We recommend using Let's Encrypt. You can set up Certbot on your server and obtain a free SSL certificate:

sudo apt install certbot
sudo certbot certonly --standalone -d your_domain.com

Step 2: Configure Reverse Proxy

Set up Nginx or Apache as a reverse proxy to handle SSL termination. This step involves configuring your web server to proxy requests to your Nextcloud container and serve traffic over HTTPS.

Troubleshooting Common Issues and Final Checks

  • Container not starting: Check logs with docker-compose logs.
  • Cannot access Nextcloud: Verify your server's firewall settings and ensure port 8080 (or your proxy port) is open.
  • SSL issues: Confirm your SSL certificates are correctly installed and configured.

Finally, ensure your server is updated regularly, and back up your Nextcloud data and database periodically.

Conclusion

Deploying Nextcloud on Ubuntu 24.04 VPS using Docker Compose is a straightforward process that offers flexibility and ease of management. With our reliable VPS hosting in Frankfurt, you can set up your private cloud quickly and securely. Whether you're a beginner or an experienced user, this method simplifies maintaining your Nextcloud instance. If you need a dependable server to host your Nextcloud, explore our VPS plans and get started today!

Read more