• Self-Host Nextcloud on Debian: The Ultimate Step-by-Step Build Guide

    Set up your own Nextcloud server on Debian — from scratch! In this step-by-step tutorial, I’ll walk you through the complete installation process, including server preparation, database setup, Apache configuration, PHP tuning, performance tweaks, securing your cloud with Let’s Encrypt (and more). Whether you’re hosting files for personal use, your business, or a homelab, this guide covers everything you need to build a fast, secure, and reliable Nextcloud instance.

    You’ll learn how to create a cloud server, configure MariaDB, optimize PHP settings, fix missing indices, enable Redis for speed, and properly secure your deployment. No skipped steps — just a full, detailed setup walkthrough you can follow with confidence.

    YouTube player
    Read more: Self-Host Nextcloud on Debian: The Ultimate Step-by-Step Build Guide

    Video Notes

    The following sections contain notes, commands, and config files that were used during this video.

    What you’ll need

    To have the best experience, you’ll need the following:

    A Linux server

    You’ll need a Linux server for this project. You can use a physical server, virtual machine, or cloud instance. In the video, a Linode instance is used on Akamai’s cloud platform. If you want to follow along exactly, you’ll need to create a Linode instance. Otherwise, you can “translate” what’s being done in the video to your chosen platform.

    Also, Debian 13 “Trixie” is used for the build within the video. Nextcloud can be set up on just about any distribution, but if you don’t choose Debian, then you’ll have to search for alternatives for some of the steps as package names and individual commands change per distro.

    Note: This video was NOT sponsored by Akamai/Linode (or anyone else for that matter). While Linode has sponsored Learn Linux TV in the past, they are not currently a sponsor. Linode was chosen only because I already have an account on the platform.

    Domain name

    While you can use Nextcloud without a domain name, it’s highly recommended that you use one. You can use your favorite domain registrar to register a domain if you don’t already have one.

    Note: After you create your Debian server, be sure to add its IP address to your DNS provider to ensure your instance is reachable by its name.

    Randomly Generated passwords

    Feel free to generate some random passwords ahead of time to use for your build. You’ll need a randomly generated password for each of the following:

    • Debian root user
    • MariaDB root user
    • Nextcloud database
    • Nextcloud admin user

    Install updates

    The first thing you should do is install all available updates, and it’s important to always do this once you set up any Linux server for the first time.

    First, update the package repository index:

    apt update

    Once that’s done, install any updates that might be available:

    apt dist-upgrade

    Update hostname

    Next, update the hostname of your Linux server to reflect the domain name you decided to use for your build. The fully qualified domain name that was used in the video was nc.learnlinux.cloud (which was used only for the recording, it doesn’t exist now – just replace it with yours).

    Update the /etc/hostname file to reflect your chosen name:

    nano /etc/hostname

    Also, update the /etc/hosts file to reflect your chosen name:

    nano /etc/hosts

    For example, you might add an entry that looks similar to this:

    127.0.1.1  nc.learnlinux.cloud  nc

    Create a non-root user

    If you don’t already have a standard user account, be sure to add one (it’s not a good idea to continually use the root account). The following command was used to create user jay within the video:

    adduser jay

    Next, add your user to the sudo group to ensure you can run privileged commands:

    usermod -aG sudo jay

    Note: Be sure to replace jay with your chosen username.

    Reboot

    Reboot the server so that it takes advantage of all of the updates:

    sudo reboot

    Set up MariaDB

    For this build, MariaDB was used to provide the required database layer.

    Install MariaDB:

    To install MariaDB, run the following command:

    sudo apt install mariadb-server mariadb-client-compat

    Check the status:

    Run the following command to ensure MariaDB is running:

    systemctl status mariadb

    If it’s not, use the following command which will ensure it’s running and also enabled (meaning it will start at boot):

    sudo systemctl enable --now mariadb

    Implement basic security:

    Since MariaDB is a big target for threat actors, we need to secure it. The following command will prompt you for various things to provide minimum security:

    sudo mysql_secure_installation

    Create a database for Nextcloud:

    Next, we’ll create the actual database that Nextcloud will end up using. To create it, enter the MariaDB shell:

    sudo mariadb

    Then, create the database:

    CREATE DATABASE nextcloud;

    Make sure it was actually created (it should appear in the list):

    SHOW DATABASES;

    Next, we’ll need to ensure Nextcloud will have access to its database. The following command will create a “user grant” that Nextcloud will use:

    GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextcloud'@'localhost' IDENTIFIED BY 'mypassword';

    Finally, exit the MariaDB shell to return back to the normal command prompt:

    exit

    Install Apache

    For this build, Apache will serve as the web server for Nextcloud. Install these packages (Apache will be installed automatically as a dependency):

    sudo apt install imagemagick-7.q16 php php-apcu php-bcmath php-cli php-common php-curl php-gd php-gmp php-imagick php-intl php-mbstring php-mysql php-zip php-xml

    Check to make sure Apache is running:

    systemctl status apache2

    Test Apache

    Visit your URL in your browser to make sure the default page loads, you should see the default Apache start page,

    Install Nextcloud

    At this point, we’ll install some additional dependencies and then copy Nextcloud’s files to the server.

    Install required packages:

    The following packages are required for Apache to be able to serve Nextcloud properly:

    sudo phpenmod apcu bcmath gmp imagick intl unzip

    Download Nextcloud:

    Next, download Nextcloud’s latest release file to the server (requires the wget package be installed):

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

    Unzip Nextcloud:

    We’ll need to use the unzip comand to extract files from the downloaded archive (the unzip package will need to be installed for this to work):

    unzip latest.zip

    Remove the Nextcloud zip file:

    We won’t need latest.zip anymore, so feel free to remove it if you don’t plan on using it again:

    rm latest.zip

    Move the Nextcloud directory to the appropriate place:

    Rename the extracted Nextcloud directory to match your server’s FQDN (optional but recommended):

    mv nextcloud nc.learnlinux.cloud

    Change ownership for the Nextcloud directory so that Apache will have access to it:

    sudo chown -R www-data:www-data nc.learnlinux.cloud


    Next, move your Nextcloud directory into the /var/www directory:

    sudo mv nc.learnlinux.cloud /var/www/

    Disable the default Apache site:

    Next, you can disable the default Apache start page since we won’t be needing it:

    sudo a2dissite 000-default.conf

    Apache Virtual Host Configuration

    Next, we’ll create a config file that will instruct Apache how to serve Nextcloud.

    Create the config file:

    sudo nano /etc/apache2/sites-available/nc.learnlinux.cloud.conf

    Add the following to the file:

    <VirtualHost *:80>
    DocumentRoot "/var/www/nc.learnlinux.cloud"
    ServerName nc.learnlinux.cloud

    <Directory "/var/www/nc.learnlinux.cloud/">
    Options MultiViews FollowSymlinks
    AllowOverride All
    Order allow,deny
    Allow from all
    </Directory>

    TransferLog /var/log/apache2/nc.learnlinux.cloud_access.log
    ErrorLog /var/log/apache2/nc.learnlinux.cloud_error.log

    </VirtualHost>

    Enable the new config file:

    sudo a2ensite nc.learnlinux.cloud.conf

    Set PHP settings

    Edit the PHP config file so we can adjust some settings:

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

    Set the following parameters:

    memory_limit = 512M
    upload_max_filesize = 200M
    max_execution_time = 360
    post_max_size = 200M
    date.timezone = America/Detroit
    opcache.enable=1
    opcache.interned_strings_buffer=16
    opcache.max_accelerated_files=10000
    opcache.memory_consumption=128
    opcache.save_comments=1
    opcache.revalidate_freq=1

    Enable required modules for Apache:

    sudo a2enmod dir env headers mime rewrite ssl

    Enable Caching:

    Open the apcu.ini file in an editor:

    sudo nano /etc/php/8.4/mods-available/apcu.ini

    Add the following to the end of the file:

    apc.enable_cli=1

    Restart Apache to apply our changes so far:

    sudo systemctl restart apache2

    Set up Nextcloud

    To apply the initial configuration, visit your Nextcloud site and answer the questions. You’ll be asked for a password for the admin user, database name, and database password. Add that information, and Nextcloud will be installed!

    Post Install: Tweak Nextcloud Database

    Although we just ran through the installer, there’s a few things Nextcloud doesn’t do on a fresh install. To implement these tweaks, first mark the occ script executable (be sure to update the path to match yours):

    sudo chmod +x /var/www/nc.learnlinux.cloud/occ

    Run the following command to add missing databases indices:

    sudo /var/www/nc.learnlinux.cloud/occ db:add-missing-indices

    Update mimetypes as well:

    sudo /var/www/nc.learnlinux.cloud/occ maintenance:repair --include-expensive

    Remove execution bit from occ to increase security:

    sudo chmod -x /var/www/nc.learnlinux.cloud/occ

    Post Install: Update config file permissions

    The following commands will increase security for the config file:

    Set ownership:

    sudo chown root:www-data /var/www/nc.learnlinux.cloud/config/config.php

    Set permissions:

    sudo chmod 660 /var/www/nc.learnlinux.cloud/config/config.php

    Post Install: Enable Caching

    To enable caching, first edit the Nextcloud config file:

    sudo nano /var/www/nc.learnlinux.cloud/config/config.php

    Add to the file:

    'memcache.local' => '\\OC\\Memcache\\APCu',
    'default_phone_region' => 'US',

    Post Install: Set up Let’s Encrypt

    To set up a certificate for encryption, we’ll first install Certbot:

    sudo apt install python3-certbot-apache

    Apply a certificate to your site:

    sudo certbot --apache -d nc.learnlinux.cloud

    To fully benefit from our certificate, enable strict transport security:

    sudo nano /etc/apache2/sites-available/nc.learnlinux.cloud-le-ssl.conf

    Add to the config file:

    <IfModule mod_headers.c>
    Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains"
    </IfModule>

    Post Install: : Install Redis

    Redis is optional, but can add performance benefits. To install it:

    sudo apt install redis-server php-redis

    Edit the Redis config file:

    sudo nano /etc/redis/redis.conf

    change: Port 6379 to 0

    Uncomment: unixsocket /run/redis/redis-server.sock

    Uncomment: unixsocketperm 700 (change to 770)

    Add the www-data user to the redis group:

    sudo usermod -aG redis www-data

    Edit the Nextcloud config file to use Redis:

    sudo vim /var/www/nc.learnlinux.cloud/config/config.php

    Add the following to the file:

      'filelocking.enabled' => true,
    'memcache.locking' => '\\OC\\Memcache\\Redis',
    'redis' =>
    array(
    'host' => '/var/run/redis/redis-server.sock',
    'port' => 0,
    'timeout' => 0.0,
    ),

    Restart Apache to apply our final changes:

    sudo systemctl restart apache2
  • How to Install Fedora 43 Step-by-Step

    Installing Fedora 43? In this step-by-step tutorial, I’ll walk you through the entire installation process — from creating the bootable USB, to testing Fedora in Live Mode, to completing the full install on your PC. Whether you’re switching from Windows or upgrading your Linux setup, this Fedora 43 guide makes the process clear, beginner-friendly, and frustration-free.

    You’ll learn how to download Fedora 43 safely, prepare installation media, explore the Live Environment, start the installer, and finish the post-install setup. If you’re new to Fedora or Linux, this video will help you get up and running confidently.

    YouTube player
  • Install and Configure ThinLinc Cluster on Linux – Full Guide

    Learn how to set up and configure a ThinLinc cluster on Linux in this complete step-by-step tutorial. This guide covers everything from downloading the ThinLinc server package to configuring master and agent nodes for a fully functional remote desktop cluster.

    YouTube player

    Thanks to Cendio/ThinLinc for sponsoring today’s video! Check out their awesome remote desktop solution here.

  • How Netdata’s Awesome AI Features Adds Fantastic Value for SysAdmins

    Discover the power of Netdata AI in this in-depth overview! 🚀 In this video, we explore how Netdata’s built-in artificial intelligence transforms infrastructure monitoring by summarizing system health, explaining alerts, detecting anomalies, and troubleshooting issues in real time. You’ll see practical examples of Netdata AI in action, plus a sneak peek at upcoming features that will make monitoring faster and smarter.

    Whether you’re a Linux system administrator, DevOps engineer, or just curious about AI-driven monitoring tools, this tutorial will show you how Netdata AI can simplify infrastructure management and help you respond to alerts more effectively.

    YouTube player

    Thanks to Netdata for sponsoring this tutorial. Check out Netdata to level-up infrastructure monitoring!

  • Linux Crash Course: How To Use “who” And “w” Commands

    Learn the difference between the Linux who and w commands in this step-by-step tutorial. Both commands are used to check who is logged into a Linux system, but they display information in different ways. In this video, you’ll see clear examples of how to use the who command to view logged-in users, and how the w command gives you more detailed information about user sessions and activity.

    This Linux command line guide is perfect for beginners who want to understand system monitoring basics and for anyone looking to strengthen their Linux skills. Whether you’re working with servers, desktops, or just learning the Linux terminal, you’ll walk away knowing how to use who and w effectively.

    YouTube player
  • tldr-pages Explained: A Better Way to Read Linux Commands

    Struggling with complicated man pages in Linux? In this video, I’ll show you how tldr-pages makes learning and using Linux commands simple, fast, and beginner-friendly. Instead of wading through walls of text, tldr-pages gives you clear, practical examples you can use right away.

    Whether you’re a Linux beginner or a seasoned system administrator, this tool will save you time and help you master the command line more efficiently. I’ll walk you through what tldr-pages is, how to install it, and why it’s one of the best Linux command cheat sheet tools available.

    YouTube player
  • Change Your Desktop Environment in Debian – Complete Guide

    Want to change the look and feel of your Debian system? In this video, you’ll learn step-by-step how to switch desktop environments in Debian, whether you’re setting up Debian for the first time or customizing an existing installation. I’ll walk you through choosing a desktop environment during installation, adding or removing desktops later with “tasksel”, selecting the right display manager (GDM, SDDM, or LightDM), and how to switch between desktop environments right from the login screen.

    Whether you prefer GNOME, KDE Plasma, XFCE, Cinnamon, or another desktop environment, this tutorial will help you install, switch, and customize Debian to match your workflow.

    YouTube player
  • Proxmox Security Updates Made Easy – Unattended Upgrades Tutorial

    Learn how to set up Proxmox unattended upgrades to automatically install security updates and patches on your Proxmox VE server. This complete tutorial covers everything from installation to configuration, ensuring your virtualization environment stays secure without manual intervention.

    YouTube player
    (more…)
  • Linux file Command Guide – How to Identify Files

    Learn how to use the Linux file command in this beginner-friendly tutorial! The file command is a powerful tool that helps you quickly identify file types on the Linux command line — whether it’s text, binary, image, or something else.

    In this video, I’ll cover the basic usage of the file command, show you several practical examples, and explain how you can use it to understand what kind of files you’re working with in Linux. If you’re learning Linux or want to sharpen your command line skills, this tutorial will help you understand one of the most useful Linux commands.

    YouTube player
  • Linux Troubleshooting with AI: Practical Tips Every Admin Should Know

    In this video, we explore 10 smart ways AI tools (like ChatGPT) can help you solve real-world Linux issues faster and more efficiently. Whether you’re debugging logs, hardening config files, or escaping dependency hell — AI can save you time and frustration!

    YouTube player
  • How to Explore Your Linux Filesystem with eza – A “Modern” ls

    Say goodbye to boring directory listings! In this video, Jay introduces you to eza – the powerful and modern alternative to the classic ls command. Learn how eza improves readability, adds color, shows icons, and even displays Git status — all right from your terminal.

    YouTube player
  • Linux Crash Course – The tree Command

    In this episode of the Linux Crash Course series, you’ll learn how to use the tree command to visualize the directory structure of your Linux system. Jay shows you how to quickly display folder contents in a tree-like format, helping you better understand file organization on the command line.

    YouTube player