Build a High-Performance Cloud Storage System on VPS with Nextcloud and S3 Backend
A guide to deploying an enterprise cloud storage system on VPS using Nextcloud with an S3 backend for optimized performance, security, and scalability.
Image credit: emkanicepic · Pixabay Content License
Introduction
In an era where businesses increasingly rely on data and require flexible, secure, and efficient cloud storage solutions, building a high-performance cloud storage system on a VPS using Nextcloud with an S3 backend is a compelling choice. This setup enables enterprises to maintain full control over their data, ensuring security and compliance without depending on large cloud providers.
Nextcloud is an open-source cloud storage platform that allows users to share, sync, and manage files like Dropbox or Google Drive, but with complete control. By integrating it with an S3 backend (such as AWS S3, MinIO, or compatible services), the system becomes highly scalable, ensures high availability, and enables robust data recovery.
Requirements and Prerequisites
- VPS Server: 4GB RAM or more, SSD storage, Ubuntu 22.04 LTS or Debian 11.
- Domain and SSL: A registered domain name and SSL certificate (Let's Encrypt is recommended).
- SSH Access: SSH access to the VPS.
- S3 Storage: An S3-compatible account (AWS S3, MinIO, Wasabi, Backblaze B2, etc.).
- Nextcloud: Latest version (19+).
Deployment Steps
1. Install Nextcloud on VPS
Run the following commands on your VPS to install Nextcloud:
sudo apt update
sudo apt upgrade -y
sudo apt install -y apache2 mariadb-server php php-mysql php-gd php-curl php-mbstring php-xml php-zip php-intl php-bcmath php-imagick php-gmp
Create a database and user for Nextcloud:
sudo mysql -u root -p
CREATE DATABASE nextcloud;
CREATE USER 'nextcloud'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextcloud'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Download and install Nextcloud:
cd /var/www/html
sudo wget https://download.nextcloud.com/server/releases/latest.zip
sudo unzip latest.zip
sudo chown -R www-data:www-data nextcloud/
sudo chmod -R 755 nextcloud/
Complete the installation via the web interface: http://your-server-ip/nextcloud.
2. Configure S3 Backend for Nextcloud
In the Nextcloud setup, go to "External Storage" and install the Nextcloud S3 Backend plugin.
Choose Amazon S3 or Other S3-compatible and enter the following details:
- Endpoint: S3 URL (e.g., s3.amazonaws.com or MinIO endpoint)
- Access Key: S3 Access Key from your account
- Secret Key: S3 Secret Key from your account
- Bucket Name: Name of the bucket where data will be stored
- Region: S3 region (if applicable)
3. Optimize Performance and Security
Perform the following optimizations:
- Enable OPcache for PHP.
- Set up Redis as a caching layer.
- Configure Nextcloud Cron via crontab:
sudo crontab -e
# Add the following line:
*/5 * * * * php /var/www/html/nextcloud/occ system:cron
Ensure that an SSL certificate is installed and access is via HTTPS.
Verification and Testing
Run the following commands to verify the setup:
# Check Apache service status
sudo systemctl status apache2
# Test S3 connection from Nextcloud
sudo -u www-data php /var/www/html/nextcloud/occ storage:scan
# Check performance
sudo php /var/www/html/nextcloud/occ maintenance:repair
Access the Nextcloud interface and upload a small file to verify storage functionality.
Troubleshooting
- Cannot connect to S3: Verify Access Key, Secret Key, and endpoint.
- Nextcloud does not display files: Check bucket access permissions and storage configuration.
- Low performance: Monitor RAM, CPU usage, and enable Redis caching.
References
High-RAM Cloud VPS Plans Optimized for AI, Databases & Cache
Enterprise RAID 10 NVMe SSDs, CMC & FPT District 9 uplinks with Anycast Anti-DDoS and 99.99% SLA.
VPS-4E
10% VAT included
- CPU: 4 vCPU
- RAM: 8 GB
- SSD: 50 GB NVMe
