Install Nextcloud
Nextcloud is a self-hosted platform for file synchronization, calendars, contacts, and collaboration. This guide deploys Nextcloud with Docker Compose, including a MariaDB database and Nginx reverse proxy.
Requirements
- A VPS running Ubuntu 20.04+ or Debian 11+
- Docker installed
- At least 2 GB RAM
- At least 20 GB free disk space (more depending on storage needs)
- A domain name pointing to your server (for SSL)
1. Connect to Your Server
ssh root@YOUR_SERVER_IP
Or use the web terminal in the Sitequest dashboard.
2. Create the Project Directory
mkdir -p /opt/nextcloud && cd /opt/nextcloud
3. Create the Docker Compose File
nano docker-compose.yml
services:
db:
image: mariadb:11
restart: always
volumes:
- db_data:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: CHANGE_ROOT_PASSWORD
MYSQL_DATABASE: nextcloud
MYSQL_USER: nextcloud
MYSQL_PASSWORD: CHANGE_DB_PASSWORD
app:
image: nextcloud:stable
restart: always
ports:
- "8080:80"
volumes:
- nextcloud_data:/var/www/html
environment:
MYSQL_HOST: db
MYSQL_DATABASE: nextcloud
MYSQL_USER: nextcloud
MYSQL_PASSWORD: CHANGE_DB_PASSWORD
NEXTCLOUD_TRUSTED_DOMAINS: your-domain.com
depends_on:
- db
volumes:
db_data:
nextcloud_data:
Replace the passwords and domain with your own values. Use strong, unique passwords.
4. Start the Containers
docker compose up -d
Wait a minute for the database to initialize, then verify:
docker compose ps
Both containers should show as "running".
5. Set Up a Reverse Proxy with SSL
If you have Nginx installed, create a server block:
nano /etc/nginx/sites-available/nextcloud
server {
listen 80;
server_name your-domain.com;
client_max_body_size 512M;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Enable and reload:
ln -s /etc/nginx/sites-available/nextcloud /etc/nginx/sites-enabled/
nginx -t && systemctl reload nginx
Then obtain SSL with Let's Encrypt:
certbot --nginx -d your-domain.com
6. Complete the Setup
Open https://your-domain.com in your browser. Create an admin account and finish the web installer.
7. Recommended Post-Install Tweaks
Run these inside the container:
docker compose exec app php occ config:system:set overwriteprotocol --value="https"
docker compose exec app php occ config:system:set default_phone_region --value="DE"
docker compose exec app php occ background:cron
Add a cron job for background tasks:
echo "*/5 * * * * docker exec nextcloud-app-1 php -f /var/www/html/cron.php" >> /etc/crontab
Next Steps
- Install the Nextcloud desktop and mobile apps for file sync
- Enable server-side encryption for sensitive data
- Set up external storage (S3, SMB) for additional backends
- Configure email notifications via SMTP
- Set up automatic backups of the
nextcloud_data and db_data volumes