Install Nextcloud - Free & Open Source Cloud Storage Solution
Table of Contents
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, 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 offer a free plan for personal use, but if you’re a business, then you’ll need to pay a massive 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 makes these companies more powerful. Recently, Europian Governments have begun to deploy their cloud solutions rather than picking any foreign-based company.
Deploying your cloud solution is not only less costly, but it gives owners complete control over their data. One of the best ways to set up a self-hosted cloud solution is Nextcloud.
Nextcloud is a free and open-source cloud storage platform one can easily set up. 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, including Android, iOS, etc.
In this article, we will set up Nextcloud on a VPS(Virtual private server).
System Requirements
We can set up Nextcloud 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
orphp-fpm
(recommended) - nginx with
php-fpm
PHP version
- 7.0
- 7.1
- 7.2
For setting up Nextcloud on localhost
If you want to set up Nextcloud for your home or local network, read the following articles on installing Linux distribution & setting up LAMP on it.
I prefer to use Ubuntu’s 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 a server with a static IP address.
For this article, I am going to set up 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
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 log in using SSH.
ssh root@165.22.184.143
You’ll be asked to type your password. 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 log in to 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.
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 the ‘adduser’ command.
adduser username
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 the 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 log in 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 log in from the current session –
su - sandy Replace sandy with your username.
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 the Nextcloud installation.
Install Nextcloud Requirements
Copy and paste the following commands to install PHP7.2 + extensions and an 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 the 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 –
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 the 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, ensure that you correctly followed all the above steps.
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. Next, we need to create a new user account & database and grant users 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 & set up 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 set up the service easily.
All we need to do is download the web installer and run the setup from the 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
To start the setup, open the web setup in a 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 set up 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 the MySQL database credentials I created above. Finally, click the ‘Finish setup’ button. And that is all.
If everything is set up correctly, you will be redirected to the 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 will never 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 questions regarding any step described above, do not hesitate to ask in the comment section below.
LinuxAndUbuntu Newsletter
Join the newsletter to receive the latest updates in your inbox.