Nextcloud is a popular open-source self-hosted cloud storage solution that allows you to store and manage your files, contacts, calendars, and more. Hosting Nextcloud on your VPS provides full control over your data and privacy, offering a secure alternative to commercial cloud storage providers like Google Drive, Dropbox, and others.
In this guide, we will walk you through the steps to install Nextcloud on your VPS for secure cloud storage.
Prerequisites
Before we begin, ensure you have the following:
- VPS with Ubuntu 20.04 LTS or later (Other distributions are supported, but this guide assumes Ubuntu).
- A domain name (Optional but recommended for easier access and SSL).
- Basic knowledge of Linux commands.
- Root or sudo user privileges.
Step 1: Set Up Your VPS
-
Access Your VPS via SSH
- Open a terminal on your local machine and SSH into your VPS:
-
Update Your VPS
- It’s always a good practice to update your system’s package lists and installed packages:
Step 2: Install LAMP Stack (Linux, Apache, MySQL, PHP)
Nextcloud requires a web server (Apache), a database server (MySQL or MariaDB), and PHP. Let's install these components.
-
Install Apache Web Server
- Install Apache:
- Start Apache and enable it to start at boot:
-
Install MySQL or MariaDB
- Install MySQL server:
- Start MySQL and enable it at boot:
-
Install PHP and Required Extensions
- Nextcloud requires PHP 7.4 or higher. Install PHP and the necessary extensions:
-
Check PHP Version
- Check the installed PHP version:
- Ensure you have PHP 7.4 or higher.
Step 3: Set Up the Database for Nextcloud
-
Log into MySQL
- Log into the MySQL root user:
-
Create a Database and User for Nextcloud
- Create a Nextcloud database and user with full privileges:
Step 4: Install Nextcloud
-
Download Nextcloud
- Download the latest stable release of Nextcloud from their official website:
-
Extract Nextcloud
- Extract the Nextcloud archive:
-
Configure Apache for Nextcloud
- Create a new Apache configuration file for Nextcloud:
-
Add the Following Apache Configuration
- Replace
your-domain.com
with your domain or VPS IP if you're not using a domain:
- Replace
-
Enable the Site and Rewrite Module
- Enable the new site and the mod_rewrite module:
-
Restart Apache
- Restart Apache to apply the changes:
Step 5: Set Up SSL (Optional but Recommended)
For better security, it’s recommended to set up HTTPS using SSL certificates. You can use Let's Encrypt to get a free SSL certificate.
-
Install Certbot
- Install Certbot and the Apache plugin:
-
Obtain an SSL Certificate
- Run the following command to automatically obtain and install the SSL certificate:
-
Verify SSL Configuration
- Check your SSL configuration:
Step 6: Configure Nextcloud
-
Access Nextcloud in a Browser
- Open your browser and go to
http://your-domain.com
orhttps://your-domain.com
if you configured SSL.
- Open your browser and go to
-
Complete the Setup Wizard
- The Nextcloud setup page will appear. Fill out the information:
- Data Folder: This is the location where Nextcloud stores files. Make sure it’s writable by Apache (
www-data
). - Database Settings: Choose MySQL, and enter the database details you set earlier:
- Database Name: nextcloud
- Database User: nextclouduser
- Database Password: your-password
- Database Host: localhost
- Data Folder: This is the location where Nextcloud stores files. Make sure it’s writable by Apache (
- After entering the database details, click Finish Setup.
- The Nextcloud setup page will appear. Fill out the information:
-
Create an Admin Account
- Create an admin user account by entering the desired username and password.
Step 7: Configure Data Storage (Optional)
You can configure external storage options, such as connecting your Nextcloud instance to an external hard drive, FTP server, or cloud storage.
- Add External Storage
- Navigate to the Nextcloud settings.
- Under the Admin section, click on External storage.
- Add your external storage options.
Step 8: Enable Additional Nextcloud Features
Nextcloud offers many features and apps for team collaboration, file sharing, and more. Some features you might want to enable include:
-
Enable the Nextcloud App Store:
- Install additional apps like calendar, contacts, and more for enhanced functionality.
-
Enable Two-Factor Authentication (2FA):
- For increased security, enable 2FA for user accounts.
Conclusion
Congratulations! You’ve successfully installed Nextcloud on your VPS for secure cloud storage. With Nextcloud, you now have full control over your data, enabling you to store, share, and collaborate with your team securely. You can also explore Nextcloud’s vast ecosystem of apps and integrations to extend its functionality and further customize your cloud storage solution.
By following this guide, you’ve created a powerful self-hosted cloud solution that provides all the benefits of major cloud storage providers while giving you complete control over your data privacy and security.