Managing your own cloud storage has become more than just a trend, it’s a necessity for privacy, performance, and complete data control. Nextcloud stands out as one of the most powerful open-source cloud platforms, allowing you to host files, collaborate with teams, sync devices, and replace third-party services like Google Drive or Dropbox entirely. When paired with Ubuntu 24.04 LTS, you get a rock-solid, long-term supported operating system that’s ideal for building a secure and future-proof cloud environment.
Here, we’ll walk you through how to install Nextcloud on Ubuntu 24.04 LTS step by step, using best-practice configurations for performance, security, and stability. Whether you’re setting up Nextcloud on a VPS, a dedicated server, or a local machine, this guide is written to be beginner-friendly while still covering important technical details that system administrators care about.
By the end of this tutorial, you’ll have a fully functional self-hosted Nextcloud server running on Ubuntu 24.04, ready for production use. No unnecessary jargon, no skipped steps—just a clean, practical installation process that works in real-world environments. Let’s get started and build your own private cloud the right way. 🚀
Install Nextcloud on Ubuntu 24.04 LTS
Looking to install Nextcloud on Ubuntu 24.04 LTS and build a private, secure, and fast file-sync cloud? This complete 2026 guide walks you through a clean, production-grade setup using
Apache, PHP 8.3, MariaDB, HTTPS, Redis caching, and cron. It’s written for beginners, but follows best practices I use when deploying Nextcloud for clients at scale.

Primary keyword target: Install Nextcloud on Ubuntu 24.04 LTS. Secondary keywords included naturally: Nextcloud installation guide 2026, Ubuntu 24.04 Apache PHP 8.3, Let’s Encrypt SSL, MariaDB, Redis locking.
What You’ll Build (and Why It’s Production-Ready)
Prerequisites
Tip: If you’d like a tuned VPS for Nextcloud with NVMe, dedicated IPv4, and 24/7 support, QloudHost can provision Ubuntu 24.04 LTS in minutes and pre-harden it for production.
Step-by-Step: Install Nextcloud on Ubuntu 24.04 LTS
Step 1 — Update server and base packages
sudo apt update && sudo apt -y upgrade
sudo apt -y install unzip curl gnupg2 ca-certificates lsb-release apt-transport-https ufw
Step 2 — Install Apache, PHP 8.3-FPM, and required PHP modules
sudo apt -y install apache2 libapache2-mod-fcgid \
php8.3 php8.3-fpm php8.3-cli php8.3-common php8.3-gd php8.3-mbstring php8.3-xml \
php8.3-zip php8.3-curl php-imagick php8.3-intl php8.3-bcmath php8.3-gmp \
php8.3-mysql php8.3-pgsql php-apcu redis-server php-redis
sudo a2enmod proxy_fcgi setenvif http2 headers env dir mime rewrite ssl
sudo a2enconf php8.3-fpm
sudo systemctl restart apache2
Why PHP-FPM? It’s faster and more scalable than mod_php, especially under concurrent loads. Enabling HTTP/2 improves performance for browsers and clients.
Step 3 — Install MariaDB and create the Nextcloud database
sudo apt -y install mariadb-server
sudo mysql_secure_installation
sudo mysql
CREATE DATABASE nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
CREATE USER 'ncuser'@'localhost' IDENTIFIED BY 'strong_password_here';
GRANT ALL PRIVILEGES ON nextcloud.* TO 'ncuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
utf8mb4 ensures proper support for emojis and international characters. Use a strong, unique password.
Step 4 — Download Nextcloud and set permissions
cd /tmp
curl -fsSL https://download.nextcloud.com/server/releases/latest.tar.bz2 -o nextcloud.tar.bz2
curl -fsSL https://download.nextcloud.com/server/releases/latest.tar.bz2.sha256 -o nextcloud.tar.bz2.sha256
sha256sum -c nextcloud.tar.bz2.sha256
sudo tar -xjf nextcloud.tar.bz2 -C /var/www/
sudo chown -R www-data:www-data /var/www/nextcloud
sudo find /var/www/nextcloud/ -type d -exec chmod 750 {} \;
sudo find /var/www/nextcloud/ -type f -exec chmod 640 {} \;
Optional but recommended: Keep data outside webroot for clarity and backups.
sudo mkdir -p /var/ncdata
sudo chown -R www-data:www-data /var/ncdata
Step 5 — Configure Apache VirtualHost for Nextcloud
sudo nano /etc/apache2/sites-available/nextcloud.conf
<VirtualHost *:80>
ServerName cloud.example.com
DocumentRoot /var/www/nextcloud
<Directory /var/www/nextcloud/>
Options FollowSymLinks
AllowOverride All
Require all granted
<IfModule mod_dav.c>
Dav off
</IfModule>
SetEnv HOME /var/www/nextcloud
SetEnv HTTP_HOME /var/www/nextcloud
</Directory>
<FilesMatch \.php$>
SetHandler "proxy:unix:/run/php/php8.3-fpm.sock|fcgi://localhost/"
</FilesMatch>
ErrorLog ${APACHE_LOG_DIR}/nextcloud_error.log
CustomLog ${APACHE_LOG_DIR}/nextcloud_access.log combined
</VirtualHost>
sudo a2ensite nextcloud.conf
sudo a2dissite 000-default.conf
sudo systemctl reload apache2
Step 6 — Enable firewall and HTTPS with Let’s Encrypt
sudo ufw allow OpenSSH
sudo ufw allow "Apache Full"
sudo ufw enable
sudo apt -y install certbot python3-certbot-apache
sudo certbot --apache -d cloud.example.com --redirect --hsts --staple-ocsp \
--email admin@example.com --agree-tos
sudo certbot renew --dry-run
HSTS prevents protocol downgrade; the OCSP stapling flag helps browsers validate certificates faster.
Step 7 — Run the web installer
Visit https://cloud.example.com and create an admin account. For data folder, choose /var/ncdata. Enter database: nextcloud, user: ncuser, password: your password, host: localhost. Finish setup.
Step 8 — Configure caching (APCu + Redis) and trusted domain
After the installer completes, add caching and domain settings for performance and security.
sudo -u www-data php /var/www/nextcloud/occ config:system:set trusted_domains 1 --value="cloud.example.com"
sudo -u www-data php /var/www/nextcloud/occ config:system:set default_phone_region --value="US"
sudo nano /var/www/nextcloud/config/config.php
'memcache.local' => '\\OC\\Memcache\\APCu',
'memcache.locking' => '\\OC\\Memcache\\Redis',
'memcache.distributed' => '\\OC\\Memcache\\Redis',
'redis' => [
'host' => '127.0.0.1',
'port' => 6379,
'timeout' => 1.5,
],
Step 9 — Switch background jobs to cron
sudo -u www-data crontab -e
*/5 * * * * php -f /var/www/nextcloud/cron.php
In Settings → Basic settings, set “Cron” as the background job mode. This ensures timely file scans, cleanup, and app tasks.
Post-Install Optimization
Tune PHP 8.3 for Nextcloud
sudo nano /etc/php/8.3/fpm/php.ini
memory_limit = 512M
upload_max_filesize = 512M
post_max_size = 512M
max_execution_time = 360
opcache.enable = 1
opcache.interned_strings_buffer = 16
opcache.max_accelerated_files = 10000
opcache.memory_consumption = 128
opcache.save_comments = 1
opcache.revalidate_freq = 60
sudo systemctl restart php8.3-fpm
sudo systemctl reload apache2
Enable HTTP/2 and gzip/brotli (Apache)
We enabled http2 already. For compression, enable deflate; brotli can be added if you install mod_brotli.
sudo a2enmod deflate
# Optional: sudo a2enmod brotli (if available)
sudo systemctl reload apache2
Security Hardening
# Trusted proxy example (if behind a reverse proxy/load balancer):
sudo -u www-data php /var/www/nextcloud/occ config:system:set trusted_proxies 0 --value="10.0.0.0/8"
sudo -u www-data php /var/www/nextcloud/occ config:system:set overwriteprotocol --value="https"
Troubleshooting Common Issues
Maintenance and Updates
Real-World Tips From the Field
If you don’t want to manage this stack yourself, QloudHost offers managed VPS and dedicated solutions pre-optimized for Nextcloud on Ubuntu 24.04 LTS, including monitoring, backups, and SLA-backed support.
Optional: Nginx Server Block (If You Prefer Nginx)
Apache is great for simplicity and .htaccess rules. If you prefer Nginx, ensure you translate rewrites and PHP-FPM handling correctly. Here’s a minimal template:
# /etc/nginx/sites-available/nextcloud
server {
listen 80;
server_name cloud.example.com;
root /var/www/nextcloud;
add_header X-Content-Type-Options nosniff;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
index index.php index.html;
client_max_body_size 512M;
fastcgi_buffers 64 4K;
location = /robots.txt { allow all; log_not_found off; access_log off; }
location ~ ^/(?:\.htaccess|data|config|db_structure|README) { deny all; }
location / {
rewrite ^ /index.php$request_uri;
}
location ~ \.php(?:$|/) {
include snippets/fastcgi-php.conf;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/run/php/php8.3-fpm.sock;
}
location ~ \.(?:css|js|woff2?|svg|gif|ico|png|jpg|jpeg)$ {
try_files $uri /index.php$request_uri;
expires 6M;
access_log off;
}
}
Then enable HTTPS with certbot –nginx. Validate with nginx -t and systemctl reload nginx.
FAQs: Install Nextcloud on Ubuntu 24.04 LTS
Is this Nextcloud installation guide valid for 2026?
Yes. Ubuntu 24.04 LTS is supported long-term, PHP 8.3 is stable, and these steps align with Nextcloud’s best practices. Always use the latest Nextcloud release (latest.tar.bz2) and keep packages updated.
Should I use MariaDB, MySQL, or PostgreSQL?
MariaDB is the easiest starting point. MySQL 8 works well too. PostgreSQL is excellent for large-scale setups. Performance differences are minor for small teams; choose the database your team can manage confidently.
How do I increase the Nextcloud upload size?
Increase PHP limits in php.ini (upload_max_filesize, post_max_size) and ensure your web server (Apache/Nginx) client body size is set accordingly. Then restart PHP-FPM and reload your web server.
Is Docker better than a native install?
Docker simplifies portability and app isolation, but adds orchestration complexity. For single-host, small-to-mid setups, native Ubuntu is straightforward and fast. For HA and scaling, containers can help—ensure you manage volumes, backups, and updates properly.
Why do I need Redis for Nextcloud?
Redis handles file locking and distributed cache, preventing race conditions and 500 errors during concurrent operations. It significantly improves reliability and performance, especially with many users or large files.
Conclusion
Installing Nextcloud on Ubuntu 24.04 LTS is a smart move if you want full control over your data, better performance, and long-term stability. With Ubuntu’s extended support and Nextcloud’s constantly evolving ecosystem, this setup is perfectly suited for personal use, businesses, and production environments well beyond 2026.
By following this guide step by step, you’ve successfully deployed a secure and self-hosted cloud platform that can handle file storage, collaboration, backups, and team workflows without relying on third-party services. From configuring the web server and database to securing your installation and optimizing performance, every step was designed to give you a reliable Nextcloud instance you can trust.
To get the most out of your Nextcloud server, keep it updated, enable recommended security features, and monitor system resources regularly. As your needs grow, you can further enhance your setup with caching, external storage, and app integrations. With the right maintenance and scaling approach, your Nextcloud installation on Ubuntu 24.04 LTS will remain fast, secure, and future-ready for years to come. 🚀


Leave a Comment