As part of building a powerful and secure homelab environment on my server, I decided to deploy Nextcloud—an open-source self-hosted cloud platform that allows you to store, sync, and share files while retaining full control over your data.
This article walks through my full installation and configuration experience, including OS setup, web server configuration, securing with HTTPS, database tuning, and optimizing performance for homelab use.
Why Nextcloud?
I chose Nextcloud because it provides:
• A full-featured alternative to Google Drive or Dropbox
• File synchronization across devices and your account
• Secure sharing and group collaboration
• Built-in calendar, contacts, notes, and task management
• Self-hosted control over sensitive data
1. Server Preparation
My homelab runs Proxmox VE, so I created a dedicated VM for Nextcloud using:
• Base OS: Ubuntu Server 22.04 LTS
• CPU: 4 cores
• RAM: 8 GB
• Disk: 100 GB SSD
• Static IP: Assigned via Proxmox bridge network
After installing Ubuntu, I updated the system:
sudo apt update && sudo apt upgrade -y
2. Install Required Packages
Nextcloud requires a web server, PHP, and database. I opted for Apache, MariaDB, and PHP 8.1:
sudo apt install apache2 mariadb-server libapache2-mod-php php php-mysql php-xml php-mbstring php-curl php-gd php-zip php-intl php-bcmath php-imagick unzip -y
3. Secure MariaDB and Create Database
First, secure the database installation:
sudo mysql_secure_installation
Then log into MariaDB and create a database and user for Nextcloud:
CREATE DATABASE nextcloud;
CREATE USER ‘nextclouduser’@’localhost’ IDENTIFIED BY ‘your_secure_password’;
GRANT ALL PRIVILEGES ON nextcloud.* TO ‘nextclouduser’@’localhost’;
FLUSH PRIVILEGES;
EXIT;
4. Download and Deploy Nextcloud
Download the latest version from the official website:
cd /var/www/
sudo wget https://download.nextcloud.com/server/releases/nextcloud-28.0.2.zip
sudo unzip nextcloud-28.0.2.zip
sudo chown -R www-data:www-data nextcloud/
Enable the Apache modules and restart:
sudo a2enmod rewrite headers env dir mime setenvif
sudo systemctl restart apache2
5. Configure Apache Virtual Host
Create a new Apache config file:
sudo nano /etc/apache2/sites-available/nextcloud.conf
Add the following:
<VirtualHost *:80>
ServerAdmin admin@yourdomain.com
DocumentRoot /var/www/nextcloud
ServerName cloud.yourdomain.com
<Directory /var/www/nextcloud/>
Options +FollowSymlinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/nextcloud_error.log
CustomLog ${APACHE_LOG_DIR}/nextcloud_access.log combined
</VirtualHost>
Enable the site and restart Apache:
sudo a2ensite nextcloud.conf
sudo a2dissite 000-default.conf
sudo systemctl reload apache2
6. Secure Your Installation with HTTPS
Install Certbot for automatic SSL with Let’s Encrypt:
sudo apt install certbot python3-certbot-apache -y
sudo certbot –apache -d cloud.yourdomain.com
Set up auto-renewal:
sudo systemctl status certbot.timer
7. Web Installer Setup
Navigate to your domain (e.g., https://cloud.yourdomain.com) and complete the Nextcloud setup:
• Choose an admin username/password
• Point to the MariaDB database you created
• Confirm installation and wait for the setup to complete
8. Recommended Configuration Tweaks
To optimize performance and stability:
Increase PHP limits:
sudo nano /etc/php/8.1/apache2/php.ini
Update:
memory_limit = 512M
upload_max_filesize = 1024M
post_max_size = 1024M
max_execution_time = 360
Restart Apache:
sudo systemctl restart apache2
Set up caching (optional):
Install Redis for memory-based caching:
sudo apt install redis-server php-redis -y
Enable in config.php:
‘memcache.local’ => ‘\\OC\\Memcache\\Redis’,
‘redis’ => [
‘host’ => ‘localhost’,
‘port’ => 6379,
],
9. Final Notes
• Enable 2FA and brute-force protection under Security Settings
• Install the mobile app for file sync and notifications
• Schedule regular backups of Nextcloud data and the database
• Monitor logs in /var/www/nextcloud/data/nextcloud.log
Conclusion
Running Nextcloud on a dedicated VM in my homelab has proven to be a powerful, privacy-focused solution. With a strong backend powered by Dell PowerEdge T430, Proxmox, and proper tuning, my setup is responsive and secure—ideal for personal use or small teams.
Self-hosting isn’t just about saving costs—it’s about control, learning, and flexibility. And Nextcloud delivers all of that.