How to Install NextCloud on Ubuntu 20.04

Install NextCloud on Ubuntu 20.04

In this article, we will have explained the necessary steps to install and configure NextCloud on Ubuntu 20.04 LTS. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

Nextcloud is an open-source file sharing and hosting solution. It is like a Google Drive / Dropbox that permits you to store, collaborate, and share documents, pictures, and videos within your organization. If you worry about privacy, you can switch to NextCloud, which you can install on your private home server or on a virtual private server (VPS). You can upload your files to your server via NextCloud and then sync those files to your desktop computer, laptop, or smartphone. This way, you have full control of your data.

Install NextCloud on Ubuntu 20.04

Step 1. First, before you start installing any package on your Ubuntu server, we always recommend making sure that all system packages are updated.

sudo apt update
sudo apt upgrade

Step 2. Install LAMP Stack.

NextCloud is built with PHP. You can host it like you would any other web app is written in PHP. So, you’re going to need to set Ubuntu up as either a LAMP server. If you haven’t done so already, use our traditional LAMP guide to set up Ubuntu to serve PHP before you continue.

Step 3. Install Nextcloud on the Ubuntu system.

Download the NextCloud zip archive onto your server. The latest stable version is 20.0.4 at the time of this writing. You may need to change the version number. Go to this page and click the download for server button to see the latest version:


Once downloaded, extract the archive with unzipping:

sudo unzip -d /var/www/

Set the directory permissions accordingly:

sudo chown www-data:www-data /var/www/nextcloud/ -R

Step 4. Creating a MariaDB database for NextCloud.

NextCloud uses the MariaDB database to store all its data like posts, pages, users, plugins, and themes settings. Log in to your MariaDB server with the following command and enter your MariaDB root password:

mysql -u root -p

Once you’re in the MariaDB console, create a new database:

MariaDB > create database nextcloud;
MariaDB > create user [email protected] identified by 'your-passwd';
MariaDB > grant all privileges on nextcloud.* to [email protected] identified by 'your-passwd';
MariaDB > flush privileges;
MariaDB > exit;

Step 4. Configuring Apache for NextCloud.

Create a new virtual host configuration file for your NextCloud website, named

nano /etc/apache2/sites-available/

And add the following content to the file:

<VirtualHost *:80>    
      ServerAdmin [email protected]
      DocumentRoot "/var/www/nextcloud"

      ErrorLog ${APACHE_LOG_DIR}/error.log
      CustomLog ${APACHE_LOG_DIR}/access.log combined

      <Directory /var/www/nextcloud/>
         Options FollowSymlinks
         AllowOverride All
         Require all granted

To enable the virtual host we have just created, run the following command:

ln -s /etc/apache2/sites-available/ /etc/apache2/sites-enabled/

For the new configuration to take effect, restart the Apache service by typing:

sudo a2ensite 
sudo a2enmod rewrite
sudo systemctl restart apache2

Step 5. Setup NextCloud.

Now you can access the Nextcloud web install wizard using an HTTP connection:

That’s all you need to do to install NextCloud on Ubuntu 20.04 Focal Fossa. I hope you find this quick tip helpful. If you have questions or suggestions, feel free to leave a comment below.