How To Install Nextcloud on Ubuntu 18.04 LTS
Nextcloud is an open source file synchronization and sharing solution. It is like a Google Drive / Dropbox that permits you to store and share your documents, pictures, and videos in a centralized location.
READ: How To Integrate Google Drive on Ubuntu 18.04 LTS
READ: How To Install Dropbox on Ubuntu 18.04 LTS
System Requirements
Nextcloud runs on top of the LAMP stack,
Linux: Ubuntu 18.04, Redhat Enterprise Linux 7, CentOS 7, Debian 9.
Apache 2.4 with mod_php
Database: MariaDB or MySQL, PostgreSQL 9 / 10, Oracle 11g.
PHP 7.1+
Nextcloud Enterprise is also available with full enterprise support, including phone and email access to Nextcloud developers.
Features
- Access your files anywhere.
- Share your files with the others and protect the public links with a password.
- Supports Two-factor authentication
- Tracking changes to your files.
- Access files stored in external cloud storage service providers like as Amazon, Google, and Dropbox.
More here.
Install Nextcloud on Ubuntu 18.04
You can set up Nextcloud on Ubuntu using Snap or LAMP stack (Official archive).
1: Install Nextcloud using snap
Install Nextcloud
You can easily install Nextcloud using the Snap command.
sudo snap install nextcloud
Output:
nextcloud 15.0.8snap2 from 'nextcloud' installed
The Nextcloud installation may take a few minutes to complete. Verify the Nextcloud installation using the below command.
sudo snap list nextcloud
Output:
Name Version Rev Tracking Publisher Notes nextcloud 15.0.8snap2 13453 stable nextcloud* -
Setup Nextcloud
Open a browser and navigate it to Nextcloud URL.
Create an admin account then click Finish setup.

Close the popup.

You will now get the home page of Nextcloud where you can upload or download your documents.

2: Install Nextcloud using Offical Archive
Prerequisites
We will install the necessary PHP extension for NextCloud.
sudo apt update sudo apt install -y php-gd php-json php-mysql php-curl php-mbstring php-intl php-imagick php-xml php-zip php-sqlite3
Now, we will install the Apache web server and MariaDB server for Nextcloud.
sudo apt install -y apache2 mariadb-server libapache2-mod-php bzip2
You need to enable a few modules to get NextCloud work properly.
sudo a2enmod rewrite
You can also enable additional Apache modules.
sudo a2enmod headers sudo a2enmod dir sudo a2enmod env sudo a2enmod mime
Restart the Apache service.
sudo systemctl restart apache2
Download Nextcloud
NextCloud offers you the zipped archives for server admin’s to download and manually set it up on top of a LAMP stack.
cd /tmp/ wget https://download.nextcloud.com/server/releases/latest.tar.bz2 tar -jxvf latest.tar.bz2 sudo mv nextcloud /var/www/html/ sudo mkdir /var/www/html/nextcloud/data
Update the ownership of files inside the NextCloud root directory so that web server can write data into it.
sudo chown -R www-data:www-data /var/www/html/nextcloud/
Create Database
If you are setting up a MariaDB server for the first time, then
READ: How To Secure MariaDB Server with mysql_secure_installation
Ensure MariaDB server service is running.
Log in to MariaDB server using the root user to create a database.
sudo mysql -u root -p
Create a database called “nextclouddb”
create database nextclouddb;
Grant “nextclouduser” to access the “nextclouddb” database on localhost with a password “password“.
grant all on nextclouddb.* to 'nextclouduser'@'localhost' identified by 'password';
Exit from the MariaDB prompt.
quit
Setup NextCloud
Open a web browser and navigate to it Nextcloud setup.
Fill up the setup page with username and password for creating an admin account, the location of the data folder and the database details.
You can choose either SQLite or MariaDB. If you decided to use the SQLite database, then you do not have to enter database details. Using SQLite server in a production environment is not recommended, so, we will use MariaDB here.

Click close to close the popup.

You will now get the home page of NextCloud. Click the “+ sign” button and then Upload File to begin uploading files.

Conclusion
I hope you have understood how to install Nextcloud on Ubuntu 18.04. As a security measure, you can consider enabling HTTPS for Nextcloud. Please share your feedback in the comments section.