Having a private cloud may, at first sight, be unnecessary, but when you are in a company and decide that it is best to take care of your files yourself, then the matter changes. That’s why, in this post, I’ll show you how to install Nextcloud on Ubuntu 20.04 with Nginx.
A private Cloud with Nextcloud
There are many data storage services in clouds. Technological giants like Apple, Google, and Microsoft have them. However, there are people or companies that want to have absolute control over their own data. Nextcloud is there for that.
Nextcloud is an open-source web application that allows us to create our own private cloud. It was created with the primary objective that it is the user who has absolute control of the files.
Many companies install Nextcloud on their servers to create their private clouds. This way they can rely on their own data management. It is even of great help in educational or personal projects.
Install Nextcloud (LEMP) on Ubuntu
1.- Install LEMP on Ubuntu 20.04
Apache is a fantastic web server and nobody can deny that. However, Nginx is well known for its great performance in high traffic situations. That’s why it’s a favorite of many sysadmins that require a lightweight and efficient server.
So, open a terminal or connect to your server and update the distribution
sudo apt update
sudo apt upgrade
Now install Nginx, along with all the PHP modules, MariaDB and some extra packages we’ll need to run:
sudo apt install nginx php7.4-common php7.4-mysql php7.4-fpm php7.4-gd php7.4-json php7.4-curl php7.4-zip php7.4-xml php7.4-mbstring php7.4-bz2 php7.4-intl php7.4-bcmath php7.4-gmp php-imagick mariadb-server unzip
Then start the php-fpm service
sudo systemctl start php7.4-fpm
And then it increases the maximum size of the uploaded files:
sudo nano /etc/php/7.4/fpm/php.ini
And it changes the value
upload_max_filesize = 2M
Set the value that you prefer, in this example, I will place
upload_max_filesize = 512M
Save the changes and close the editor.
Now configure MariaDB with the
And there you can define the root password and secure the installation of MariaDB
Remove anonymous users? [Y/n]
Disallow root login remotely? [Y/n]
Remove test database and access to it? [Y/n]
Reload privilege tables now? [Y/n]
Now create the database as well as the user who will use Nextcloud:
sudo mysql -u root -p
CREATE DATABASE nextcloud;
GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextclouduser'@'localhost' IDENTIFIED BY 'nextcloudpss';
Now we can start the installation.
2.- Download Nextcloud
Now if you can download Nextcloud, you can use the wget command
cd /tmp/ wget -c https://download.nextcloud.com/server/releases/nextcloud-20.0.4.zip --2021-01-11 16:11:32-- https://download.nextcloud.com/server/releases/nextcloud-20.0.4.zip Resolving download.nextcloud.com (download.nextcloud.com)… 2a01:4f9:2a:3119::181, 184.108.40.206 Connecting to download.nextcloud.com (download.nextcloud.com)|2a01:4f9:2a:3119::181|:443… connected. HTTP request sent, awaiting response… 200 OK Length: 142325595 (136M) [application/zip] Saving to: ‘nextcloud-20.0.4.zip’ nextcloud-20.0.4.zip 100%[=====================================================================================>] 135.73M 57.8MB/s in 2.4s 2021-01-11 16:11:35 (57.8 MB/s) - ‘nextcloud-20.0.4.zip’ saved [142325595/142325595]
After that, unzip it in the Nginx root directory:
sudo unzip nextcloud-20.0.4.zip -d /var/www/html/
Change the owner of the folder:
sudo chown -R www-data:www-data /var/www/html/
Now create a new ServerBlock with the following guidelines that will facilitate the documentation of Nextcloud:
Remember to change the ServerName values to your own. Save the changes and close the editor
Check the Nginx configuration to make sure everything is fine:
sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
And now you have to get a certificate for your domain. This is quite simple thanks to Certbot.
sudo apt install certbot python3-certbot-nginx
Then you can start the process:
sudo certbot --nginx --agree-tos --redirect --hsts --staple-ocsp --email email@example.com -d angtest.ga
Replace the email and domain values with your own.
At the end of the process, apply the changes by restarting nginx.
sudo systemctl reload nginx
3.- Install Nextcloud
Now open your web browser and go to
https://your-domain and you will see the following screen
There you will have to create the administrator user and configure the database parameters below.
You can also change the path where the data is stored, but you have to create the folder on your server.
When you are ready, Nextcloud will be ready for you.
So, enjoy it.
Nextcloud is a very useful tool for small and medium businesses that want to create a private cloud quickly and secure.