It is said that the data is the new oil of the modern world. We all know how companies mine data and sell it to other companies. Not only that but recently the use of cloud storage has also risen up which means people have now started using cloud storage to store their important data.
Google, Microsoft, Apple, Yandex, and almost all other major companies provide cloud storage solutions. All of these services provide a free plan for personal use but if you’re a business, then you’ll need to pay a huge amount of money to expand your storage.
Even after you subscribe to their premium services, your data stays on their servers and they can control it however they want which make these companies more powerful. Recently, Europian Governments have begun to deploy their own cloud solutions rather than picking any foreign-based company.
Deploying your own cloud solution is not only less costly but it gives owner complete control over their data. One of the best ways to setup a self-hosted cloud solution is Nextcloud.
Nextcloud is a free and open-source cloud storage platform one can easily setup. It is the best free & open-source alternative to Google Drive or Dropbox.
Like any other popular cloud service, you can deploy Nextcloud and have your family or employee use it on any device they have including, Android, iOS etc.
In this article, we are going to setup Nextcloud on a VPS(Virtual private server).
Nextcloud can be setup on all major Linux distributions.
- Ubuntu 18.04 LTS (Recommended)
- Red Hat Enterprise Linux 7 (Recommended)
- Debian 8 (Jessie), 9 (Stretch)
- SUSE Linux Enterprise Server 11 with SP3 & 12
- openSUSE Leap 42.1+
- CentOS 7
- MySQL 5.x or MariaDB 5.5+ (recommended)
- Oracle Database 11g (only as part of an enterprise subscription)
- PostgreSQL 9/10
- SQLite (only recommended for testing and minimal-instances)
- Apache 2.4 with
- nginx with
For setting up Nextcloud on localhost
If you want to setup Nextcloud for your home or local network, then read the following articles on installing Linux distribution & setting up LAMP on it.
I prefer to use Ubuntu latest LTS version for all my projects.
Install Ubuntu Minimal version.
Ubuntu Minimal Install
Once we have installed Ubuntu, we can install other required packages for Nextcloud.
If you are setting up Nextcloud on localhost, you can follow these steps without any problems. If you are a small or big company, you need to have a server with a static ip address.
Create a Ubuntu Server on Digitalocean
It takes 2 to 3 minutes for the server to be ready to connect. Once the server is ready, it shows the ip address on the dashboard. The setup process automatically creates a root user and sends the password to the user’s registered email.
From the dashboard copy the IP address of the server and login using SSH.
You’ll asked to type your password. Simply copy the password from the email sent to your registered email id and paste it here.
For security purposes, the default password must be changed when you login on the server for the first time. So after you are logged in to your server, you’ll be asked to retype your current password and enter a new password.
Make a strong password. Include string, numbers, and symbols to make it strong.
You can check your password strength here. This tool shows the time different system takes in cracking your password. It is very important to use this tool to figure out the strength of your passwords.
Create a new user account on Ubuntu
By default, the server creation process creates a root user. It is not recommended to use root all the time. We can create a new server user and give it sudo access to make it perform administrative tasks.
To create a new user, we use ‘adduser’ command.
Add user to sudo group
Until this point, you won’t be able to use sudo with the newly created account. Add the new user account to sudo group.
usermod -aG sudo sandy
It is all done! We now have a server running with a new user account that can use sudo. 🙂
You can login to the new user account from the current session using the following command or log out of the root user and create a new session.
To login from the current session –
su - sandy Replace sandy with your username.
Login to new server user
Update your Server
The very first thing to do after logging in to the server is to update it. We use apt package manager to update Ubuntu Linux.
sudo apt update && sudo apt upgrade -y
The update process may take a long time depending on your internet speed. If you’re using VPS like in my case, it won’t take more than 3 minutes.
Once the server finishes installing updates, reboot the server using the following command –
Reboot usually takes 30s-1m. So try logging in to the server after 1 minute.
Now our server is ready and we can start to prepare Nextcloud installation.
Install Nextcloud Requirements
Copy and paste the following commands to install PHP7.2 + extensions and apache web server.
sudo apt install php7.2 php7.2-zip php7.2-zip php7.2-xml php7.2-gd php7.2-curl php7.2-mbstring php7.2-mysql mysql-server sudo apt install apache2
After the installation completes, visit your server ip address in web browser. If you are setting up Nextcloud on your local server, visit
You should see the following page –
If you do not see the above page, check that apache server running status.
sudo service apache2 status
You should have the following output in terminal –
As you can see above, the apache is active. If you see it inactive, it means the apache service is not running. Start apache using the following command –
sudo service apache2 start
If you still do not see the Ubuntu apache page, make sure that you’ve followed all the above steps correctly.
Setup apache configuration file for Nextcloud.
sudo nano /etc/apache2/apache2.conf
Change the following lines –
<Directory /var/www/> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory>
<Directory /var/www/> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory>
Create Mysql user and database for Nextcloud
Login to mysql cli –
It will log you into your mysql root account. The next we need to create a new user account & database and grant user all privileges over the database.
CREATE USER 'sohail'@'localhost' IDENTIFIED BY 'some_pass'; GRANT ALL PRIVILEGES ON *.* TO 'sohail'@'localhost' WITH GRANT OPTION; CREATE database nextcloud; GRANT ALL PRIVILEGES ON nextcloud.* TO 'sohail'@'localhost'; FLUSH PRIVILEGES;
There are multiple ways we can install & setup Nextcloud on our server but the easiest is using the web installer. Nextcloud team has built an easy to use web installer to install and setup the service easily.
All we need to do is download the web installer and run the setup from web browser.
Download web installer using
wget and move it in
wget https://download.nextcloud.com/server/installer/setup-nextcloud.php && sudo mv setup-nextcloud.php /var/www/html Make the apache server own the server directory to avoid any permission related issues. sudo chown -R www-data /var/www/html
To start the setup, open the web setup in web browser.
http://your-ip-address/setup-nextcloud.php My server ip is - 188.8.131.52 If you are setting up on your local server, visit localhost/setup-nextcloud.php or 127.0.0.1/setup-nextcloud.php http://184.108.40.206/setup-nextcloud.php
The setup page will open. You can now easily follow the on-screen instructions to setup Nextcloud. But don’t worry, I will also guide you through the complete setup.
Click next to check all the dependencies.
If you want to install Nextcloud in a sub-directory, then you can enter the directory name here otherwise enter ‘.’ (without quotes) to install it in the root directory.
As you can see I have used mysql database credentials I created above. Finally click ‘Finish setup’ button. And that is all.
If everything setup correctly, you will be redirected to Nextcloud main page.
As you can see the interface is very similar to Dropbox and Google drive. The only difference is that the data you store here is never going to be used by anyone else. It is your data and you can control it.
As your cloud storage has more and more users, you can expand your server size easily on Digitalocean.
So this was the basic setup of Nextcloud, a free and open source cloud platform. I will be covering more articles on making Nextcloud more useful.
If you have any question regarding any step described above, do not hesitate asking it in the comment section below.