Blogging Knowledge Base

How to Install NextCloud From Command Line? 2026 Brief Guide

To install NextCloud from the command line, prepare a LEMP/LAMP stack, create a database, download the Nextcloud tarball, configure your web server (Nginx or Apache), run the occ CLI installer, enable HTTPS, and set up cron and caching (Redis).

The steps below cover Docker, Snap, and production-grade manual installs.

If you want a private, self-hosted cloud with full control, learning how to Install NextCloud From Command Line is the fastest and most reliable path.

This guide walks you through Docker, Snap, and a hardened Ubuntu/Debian stack with Nginx, PHP-FPM, MariaDB, and Redis—entirely via CLI.

Install NextCloud From Command Line

What you’ll Learn Here (and what you need)

This tutorial is designed for beginners and sysadmins alike. You’ll learn repeatable commands to deploy, secure, and maintain Nextcloud. We’ll use Ubuntu/Debian for examples (24.04/22.04 and 12/11), with notes for RHEL/CentOS/Rocky. You’ll need:

  • A fresh VPS or dedicated server (2+ vCPU, 4 GB RAM recommended, SSD storage)
  • Root or sudo access
  • A domain pointing to your server (e.g., cloud.example.com)
  • Ports 80 and 443 open in firewall

Quick Start: Docker One-Liner (fastest way)

Use Docker for a quick, reproducible CLI deployment. The command below starts Nextcloud with SQLite (great for testing). For production, pair Nextcloud with MariaDB/PostgreSQL and Redis (compose file suggested).

Add a reverse proxy and Let’s Encrypt (e.g., Traefik or Nginx Proxy Manager) to serve your domain over HTTPS.


Production-grade CLI Install (Ubuntu/Debian + Nginx + PHP-FPM + MariaDB + Redis)

This is the most common, performance-friendly stack for Nextcloud. All steps are strictly via command line.

1) Update server and install packages


2) Create database and user


3) Download NextCloud and set permissions


4) Configure Nginx for Nextcloud

Replace cloud.example.com with your domain. This config targets PHP-FPM’s default socket and includes best practices for caching and security.


5) Get a free SSL certificate (Let’s Encrypt)


6) Run the NextCloud CLI installer (occ)


7) Enable Redis Caching and Cron

Visit https://cloud.example.com, log in as admin, and verify there are no critical warnings under Administration > Overview.


Alternative: Install NextCloud with Snap (simplest CLI)

Snap bundles everything for you. It’s easy to maintain, though less flexible than a manual or Docker setup.


RHEL/CentOS/Rocky Linux quick notes (CLI)

Enable newer PHP via Remi or AppStream, then proceed similarly to Ubuntu. Example:


Post-install Hardening and Performance Tips

  • Increase PHP limits for large files: memory_limit=512M, upload_max_filesize=512M, post_max_size=512M, max_execution_time=360
  • Enable and tune OPcache (php.ini): opcache.enable=1, opcache.memory_consumption=256, opcache.interned_strings_buffer=16, opcache.max_accelerated_files=10000, opcache.save_comments=1
  • Force HTTPS and enable HSTS once validated
  • Put Nextcloud behind a CDN or reverse proxy if serving many users
  • Move data directory to a larger disk or block storage for scale
  • Enable previews with a cron job for better UX: occ preview:generate-all

Essential NextCloud CLI (occ) Commands


Troubleshooting From the Command Line

  • Permissions: Ensure /var/www/nextcloud is owned by www-data (or your web user).
  • Logs: Check /var/www/nextcloud/data/nextcloud.log, /var/log/nginx/error.log, and PHP-FPM logs.
  • Database connectivity: Verify credentials and socket/host in config.php.
  • PHP modules: Confirm required extensions are installed and loaded.
  • SELinux (RHEL-based): Apply proper contexts and allow network connections for PHP-FPM if needed.

Real-world Guidance From Hosting Experience

For teams and SMBs, reliability matters more than the novelty of the stack. Use Nginx + PHP-FPM with Redis, dedicate fast SSD storage, and keep nightly offsite backups. Monitor disk inode usage, database growth, and PHP-FPM pool saturation to prevent bottlenecks long before users notice slowdowns.

Why host NextCloud With QloudHost

If you’d prefer to skip trial-and-error, QloudHost’s SSD-powered VPS plans are optimized for PHP workloads and include dedicated resources, root access, and optional managed support.

Visit QloudHost

We can pre-harden your Nextcloud stack (Nginx, MariaDB, Redis, HTTPS) and help you scale confidently while you focus on your data, not server plumbing.


FAQs: Install NextCloud From Command Line

Can I install Nextcloud entirely without a web browser?

Yes. Use the occ CLI installer to create the admin account and connect the database. With a proper Nginx/Apache config and HTTPS in place, your instance will be ready. You can also manage users, apps, and maintenance tasks entirely via occ.

What’s the easiest command-line method for beginners?

Snap is the simplest option: snap install nextcloud, then nextcloud.manual-install and nextcloud.enable-https. Docker is the next easiest for reproducibility. The manual Nginx/PHP stack offers the most control and performance for production.

Which database should I use for Nextcloud?

MariaDB and PostgreSQL are both robust. MariaDB is popular and well-documented; PostgreSQL excels at concurrency. Avoid SQLite for multi-user production systems—it’s fine for light testing or personal use but not for scale.

How much RAM and CPU does Nextcloud need?

For small teams (up to ~20 users), 2 vCPU and 4 GB RAM is a practical baseline with Redis caching. Increase resources as user count, apps (Collabora/ONLYOFFICE), and file preview workloads grow.

How do I enable HTTPS for a CLI-only deployment?

Use Certbot. On Ubuntu/Debian with Nginx: certbot –nginx -d cloud.example.com –redirect. Ensure DNS points to your server and ports 80/443 are open. For Snap installs, use nextcloud.enable-https lets-encrypt. For Docker, add a reverse proxy (Traefik or Nginx Proxy Manager) with automated certificates.

Conclusion

With these steps, you can install, secure, and operate Nextcloud completely from the command line—whether you pick Docker, Snap, or a production-ready Nginx + PHP-FPM stack.

Keep your system updated, monitor resources, and you’ll have a fast, private cloud ready for work.

Leave a Comment