Install Nextcloud – Free & Open Source Cloud Storage Solution

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.

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.

Our sponsor - Deploy your server within 3 minutes

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).

System Requirements

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

Database requirements

  • 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)

Server

  • Apache 2.4 with mod_php or php-fpm (recommended)
  • nginx with php-fpm

PHP version

  • 7.0
  • 7.1
  • 7.2

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.

Setup server

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.

For the purpose of this article, I am going to setup a Ubuntu 18.04 droplet on Digitalocean. It takes minutes to create a server up and running on Digitalocean.

Create a Ubuntu Server on Digitalocean

Create Ubuntu server on digitalocean
Create Ubuntu server on Digitalocean
Select server location on Digitalocean
Select server location on Digitalocean
Finalize & Create server
Finalize & Create server

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.

Server running on Digitalocean
Server running on Digitalocean

From the dashboard copy the IP address of the server and login using SSH.

ssh root@165.22.184.143

You’ll asked to type your password. Simply copy the password from the email sent to your registered email id and paste it here.

Login to server using SSH
Login to server using SSH

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.

Set a new root password
Set a new root password

Notice

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.

adduser username
Create a new server user
Create a new server user

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 user account
Login to new user account

Login to new server user

ssh sandy@165.22.184.143

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 –

sudo reboot

Reboot usually takes 30s-1m. So try logging in to the server after 1 minute.

ssh sandy@165.22.184.143

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 localhost or 127.0.0.1.

You should see the following page –

Apache server running on Ubuntu server
Apache server running on Ubuntu server

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 –

Apache running status
Apache running status

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>

To

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>

Create Mysql user and database for Nextcloud

Login to mysql cli –

sudo mysql

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;

Install Nextcloud

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 /var/www/html directory.

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
Download Nextcloud web installer
Download Nextcloud web installer

To start the setup, open the web setup in web browser.

http://your-ip-address/setup-nextcloud.php

My server ip is - 165.22.184.143

If you are setting up on your local server, visit localhost/setup-nextcloud.php or 127.0.0.1/setup-nextcloud.php

http://165.22.184.143/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.

Nextcloud web installer
Nextcloud web installer
Nextcloud install directory
Nextcloud install directory

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.

Nextcloud installation completed
Nextcloud installation completed
Create Nextcloud admin account & setup Database & storage
Create Nextcloud admin account & setup Database & storage

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.

Nextcloud storage
Nextcloud storage

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.

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.

Our sponsor - Deploy your server within 3 minutes

Leave A Reply

Your email address will not be published.

2 Comments
  1. Jeremy says

    Why create a brand new tutorial on installing NextCloud 16 when NC17 is already out?

    1. Sohail says

      The article was published on 16, Sept. and NC 17 came out on 30 Sept. But still, there should not be any issue with this article. The script that you download in the article always downloads the latest Nextcloud version. That’s why I did not have to mention the version in the article.

      I will now cover NC 17 also. 🙂

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. AcceptRead More