What is NextCloud?
How to install NextCloud on Ubuntu 20.04 with NGINX
- The server uses Ubuntu 20.04 (refer to the best VPS service here)
- RAM: 1GB (Minimum, but for better performance, you should use VPS with high RAM configuration)
- CPU: 1 Core
- Disk: 20GB
Step 1: SSH into the server
First, you need to SSH into the server to perform the installation. If you do not know how to do this, please refer to the documentation below:
Step 2: Update the system
sudo apt update sudo apt upgrade apt install unzip -y
Step 3: Install LEMP Stack
Instead of using APACHE (LAMP Stack), I always prefer to use NGINX as a web server. Please perform the installation with the following commands:
- Install NGINX
You can install NGINX with the following command:
apt install nginx -y
Enable & Start NGINX
systemctl enable nginx systemctl start nginx systemctl status nginx
- Install MariaDB Database Server
I will be using MariaDB as the database server. Please install with the following command:
apt install mariadb-server mariadb-client -y
Enable & Start MariaDB
systemctl enable mariadb systemctl start mariadb systemctl restart mariadb systemctl status mariadb
MariaDB Security Configuration
- Install PHP
I will install PHP7.4 and the included extensions.
apt install imagemagick php-imagick php7.4-imagick 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 php7.4-zip apt install -y libmagickcore-6.q16-6-extra
Enable and Start PHP with the system
systemctl enable php7.4-fpm systemctl start php7.4-fpm systemctl status php7.4-fpm
Step 4: Get an SSL certificate for NextCloud ServerName
I will show you to install SSL Let’s Encrypt using Certbot.
- Install Certbot
apt install certbot python3-certbot-nginx
Python3-certbot-nginx is an Nginx plugin for Certbot. Now run the following command to get and install the TLS certificate.
luutru.azdigi.online with your domain name.
certbot certonly --standalone -d luutru.azdigi.online
After the SSL certificate request is completed, you will receive 2 links, as shown in the image above. Copy this link to use for Step 5.
Step 5: Install NextCloud
After setting up the webserver and database server, we will start downloading the source and installing NextCloud.
- Download the NextCloud source from the homepage.
In this tutorial, I will install the latest version, currently 23.0.3.
- Extract the downloaded NextCloud file
unzip nextcloud-*.zip -d /usr/share/nginx/ chown -R www-data:www-data /usr/share/nginx/nextcloud/
- Create a database for NextCloud
Next, you log in to mysql with the
mysql command and create database_name and database_user for Nextcloud.
create database azdigi_db; create user azdigi_user@localhost identified by 'my-passwd'; grant all privileges on azdigi_db.* to azdigi_user@localhost identified by 'my-passwd'; flush privileges; exit;
- Create NGINX NextCloud configuration file
Now create an Nginx configuration file for Nextcloud to use.
Then you enter the content of the sample configuration file below:
server_name luutru.azdigi.online; with your server_name. Replace ssl_certificate and ssl_certificate_key with the SSL path you got in Step 4.
After importing the configuration file, check for errors with the following command:
root@drive:~# nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful
If you receive the message
syntax is ok, please restart NGINX:
root@drive:~# service nginx restart
After restarting the NGINX service, you can open the browser and access the
hostname to continue the NextCloud setup steps.
Click Install recommended apps to install the required apps.
After completing the installation of the applications, if the admin interface screen appears as below, you have successfully installed the setup.
Step 6: Create a User and Upload File
To create a User, first, in the admin interface, you click on the Profile icon => select Users => New user
At the New user interface, you enter the information you need to set for that User, including:
- Display name
- Add user to group
- Select capacity for User
Once created, you can log in to the User and upload the file.
Step 7: Advanced Configuration
- Memory Limit configuration
NextCloud requires 512MB memory_limit. So you can make changes in
php.ini with the following command:
sudo sed -i 's/memory_limit = 128M/memory_limit = 512M/g' /etc/php/7.4/fpm/php.ini
- Set up PHP to properly query system environment variables
sudo sed -i 's/;clear_env = no/clear_env = no/g' /etc/php/7.4/fpm/pool.d/www.conf
- Increase upload limit
sudo sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 1024M/g' /etc/php/7.4/fpm/php.ini
- Change default_phone_region
You open the file
/usr/share/nginx/nextcloud/config/config.php and add the following line above
'default_phone_region' => 'VN'
- Install Redis Cache
apt install redis-server -y apt install php-redis -y systemctl start redis-server systemctl enable redis-server systemctl status redis-server
After the Redis installation is complete, open the file
vi /usr/share/nginx/nextcloud/config/config.php and add the following lines to the file
'memcache.distributed' => '\OC\Memcache\Redis', 'memcache.local' => '\OC\Memcache\Redis', 'memcache.locking' => '\OC\Memcache\Redis', 'redis' => array( 'host' => 'localhost', 'port' => 6379, ),
Next, you restart the nginx and php-fpm services.
service nginx restart systemctl restart php7.4-fpm
- Mail User Configuration
You access the Profile icon => select Settings => Email and enter the admin email you need to receive information.
- SMTP Configuration
To configure SMTP, go to Basic settings => enter your SMTP configuration information. Next, click Send email and if it shows Email sent is successful.
After the installation and configuration are complete, you go to your website and if it shows the Green Tick as shown below, it means everything is working fine and safely. So we have completed the steps to install NextCloud on Ubuntu 20.04 with NGINX.
Wishing you success!
You can refer to other user manuals at the link below
If you need assistance, you can contact support in the ways below:
- Hotline 247: 028 730 24768 (Ext 0)
- Ticket/Email: You use the email to register for the service and send it directly to: email@example.com