Nextcloud
Version: Latest | OS: Ubuntu 22.04
Overview
Nextcloud is a secure and self-hosted content collaboration platform, allowing users to store, sync, and share files, contacts, calendars, and more. It provides full control over data and is ideal for both individual and enterprise use.
Included Software
- Nextcloud - Latest stable release
- Apache - 2.4.x
- MySQL - 8.0.x
- PHP - 8.1 or 8.2
- Redis - for caching and session storage
- Fail2ban - for brute-force protection
- Certbot - for SSL certificate management
- Postfix - for sending outbound mail
Getting Started
Firewall & Access
Ensure the following ports are allowed through your firewall:
Port | Service | Purpose |
---|---|---|
22 | SSH (rate limited) | Server access |
80 | HTTP | Web traffic |
443 | HTTPS | Secure web traffic |
Initial Setup Process
Upon first boot:
- The MySQL root password is set and
mysql_secure_installation
is run. - Apache and PHP are configured.
- Nextcloud files are placed in the web root.
- Nextcloud admin credentials and database settings are initialized.
You will be disconnected with the message:
Please wait until the installation is completed....
Connection to $IPADDRESS closed.
Please wait at least 2 minutes before logging back in.
Accessing the Instance
- Login as
ubuntu
via SSH. - Switch to root:
sudo su -
Admin and database credentials will be displayed on first login. All credentials are stored for future reference in:
- MySQL root password:
/root/.mysql_root_password
- Nextcloud DB details:
/root/.nextcloud_database_details
- Nextcloud admin login:
/root/.nextcloud_admin_credentials
Accessing Nextcloud Dashboard
Visit http://$IPADDRESS
or your domain name in a web browser.
Domain Configuration (Optional but Recommended)
- Ensure the domain's A record points to your instance.
- Set the domain in Nextcloud's trusted domains:
sudo -u www-data php /var/www/html/occ config:system:set trusted_domains 1 --value="yourdomain.com"
- Set the server name in Apache:
sed -i 's/#ServerName .*/ServerName yourdomain.com/' /etc/apache2/sites-available/000-default.conf
- Restart Apache:
systemctl restart apache2
SSL Setup with Certbot
Use Certbot to secure your Nextcloud instance with HTTPS:
certbot --apache -d yourdomain.com -d www.yourdomain.com
Make sure both A
and www A
records are properly pointed before running the above command.
Postfix Configuration
- Set a valid hostname:
hostnamectl set-hostname your.hostname.com
- Ensure PTR and A records exist for the hostname.
- Edit
/etc/postfix/main.cf
:
myhostname = your.hostname.com
- Restart Postfix:
systemctl restart postfix
- Test email delivery:
echo "Test email from Nextcloud" | mail -s "Subject" you@example.com
Emails may initially land in spam due to new IP reputation.
Best Practices
- Regularly back up Nextcloud files and its database.
- Keep your Nextcloud instance updated for security and performance.
- Use fail2ban and firewall rules to protect from brute-force attacks.
- Configure external storage and collaborative apps from the Nextcloud app store as needed.
For assistance, contact Cloud4India Support.