If you’ve ever wanted to ditch third-party cloud services like Google Drive or Dropbox and take full control of your files, Nextcloud is the perfect solution. It’s a powerful, open-source cloud platform that you can self-host on your Ubuntu server—giving you privacy, flexibility, and total ownership of your data.
In this post, we’ll walk through the full setup of Nextcloud on an Ubuntu Server. Whether you’re running a VPS or a local machine, you’ll be up and running in no time.
📦 What is Nextcloud?
Nextcloud is a free and open-source file hosting service that you can run on your own server. Think of it as your own private Google Drive—complete with file sharing, syncing, collaborative editing, calendar, contacts, and even apps!
🧰 Requirements
- A server running Ubuntu 20.04 or 22.04
- A non-root user with sudo privileges
- A domain name (optional but recommended)
- Basic familiarity with the command line
⚙️ Step 1: Update Your System
sudo apt update && sudo apt upgrade -y
🐘 Step 2: Install Required Packages
We’ll install the LAMP stack (Linux, Apache, MySQL, PHP), since Nextcloud runs on it.
sudo apt install apache2 mariadb-server libapache2-mod-php php php-gd php-json php-mysql php-curl php-mbstring php-intl php-imagick php-xml php-zip unzip -y
🛠️ Step 3: Configure the Database
- Secure your MariaDB installation:
sudo mysql_secure_installation
Answer the prompts—set a root password, remove anonymous users, disallow remote root login, etc.
- Create a database and user for Nextcloud:
sudo mysql -u root -p
CREATE DATABASE nextcloud;
CREATE USER 'nextclouduser'@'localhost' IDENTIFIED BY 'strongpassword';
GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextclouduser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
📥 Step 4: Download Nextcloud
wget https://download.nextcloud.com/server/releases/latest.zip
unzip latest.zip
sudo mv nextcloud /var/www/
Set the right permissions:
sudo chown -R www-data:www-data /var/www/nextcloud
🌐 Step 5: Configure Apache
Create a new config file:
sudo nano /etc/apache2/sites-available/nextcloud.conf
Paste this in:
<VirtualHost *:80>
DocumentRoot /var/www/nextcloud
ServerName yourdomain.com
<Directory /var/www/nextcloud/>
Require all granted
AllowOverride All
Options FollowSymLinks MultiViews
</Directory>
ErrorLog ${APACHE_LOG_DIR}/nextcloud_error.log
CustomLog ${APACHE_LOG_DIR}/nextcloud_access.log combined
</VirtualHost>
Enable the site and modules:
sudo a2ensite nextcloud.conf
sudo a2enmod rewrite headers env dir mime
sudo systemctl restart apache2
🔐 Step 6: Secure with HTTPS (Let’s Encrypt)
Install Certbot:
sudo apt install certbot python3-certbot-apache -y
Generate the SSL certificate:
sudo certbot --apache -d yourdomain.com
This will auto-renew every 90 days.
🚀 Step 7: Complete the Web Installer
Visit your domain or IP in your browser:
http://yourdomain.com
You’ll be greeted by the Nextcloud setup screen.
- Set your admin username and password
- Enter the database info you set earlier
- Click Finish Setup
🎉 That’s it! You’ve got your own cloud server.
🧩 Optional: Enable Recommended Features
Once inside the dashboard, consider installing:
- Nextcloud Office for document editing
- Calendar and Contacts apps
- External storage to connect Google Drive, Dropbox, etc.
✅ Final Tips
- Backup your data regularly (
rsync
,rclone
, or built-in tools) - Keep your Ubuntu server and packages updated
- Monitor logs with
journalctl -u apache2
orhtop
📌 Wrapping Up
You’ve now got a fully-functional, self-hosted cloud running on your own Ubuntu server. Whether it’s for personal use, your dev team, or your entire organization, Nextcloud gives you total control over your data—without monthly fees or data harvesting.
Need help setting it up with Docker or behind a reverse proxy like Nginx? Let me know—I’d be happy to write a follow-up