How to Install NextCloud on Ubuntu 16.04

In the future, using the website, you agree to the rules of using Cookies. Read more. I agree

How to install NextCloud on Ubuntu 16.04

NextCloud is a free, open source file sharing application like Dropbox. You can securely share files, folders, documents, emails, contacts, bookmarks and appointments using NextCloud. NextCloud provides a user-friendly web interface so that you can easily access your files through a web browser from a public and private network or from any device.

This is fully open source, but it charges a support fee. NextCloud also allows you to share your files with other users, create password-protected links to allow other users to upload files to your cloud.

In this tutorial, we will see how to install and use NextCloud on an Ubuntu 16.04 server.

# Prerequisites

  • Server running Ubuntu 16.04.
  • Server under control Non-root user with sudo privilege settings on your Ubuntu 16.04 server.
  • The static IP address is configured on your server.
  • Update system

    First upgrade the system to the latest stable version by running the following command:

    sudo apt-get update -y sudo apt-get upgrade -y

    Once your system is updated, you can proceed to the next step.

    Install LAMP Stack

    Before you begin, you need to install Apache, MariaDB, PHP7 and other necessary PHP modules on your system.

    You can install them by running the following command:

    sudo apt-get install apache2 mariadb-server php7.0 libapache2-mod-php7.0 php7.0-mbstring php7.0-curl php7.0-json php7.0-intl php7.0-imagick php7.0-xml php7.0-mbstring php7.0-zip php7.0-gd php7.0-mysql php7.0-curl php7.0-mcrypt

    After the installation is complete, start the apache and mariadb services and enable them at boot using the following command:

    sudo systemctl start apache2 sudo systemctl start mysql sudo systemctl enable apache2 sudo systemctl enable mysql

    Then you need to configure some php options to make Nextcloud work correctly. You can do this by editing the php.ini file:

    sudo nano /etc/php/7.0/apache2/php.ini

    Change the following values:

    memory_limit = 1000M
    date.timezone = Asia/Kolkata
    upload_max_filesize = 200M
    post_max_size = 200M

    Save and close the file when you are done, then you can go to the next step.

    Database Setup for NextCloud

    By default, the MariaDB installation is not protected, so you need to protect it first.

    You can protect it by running the mysql_secure_installation script.

    sudo mysql_secure_installation

    Answer all questions as shown below.:

    Enter current password for root (enter for none):
    Change the root password? [Y/n] n
    Remove anonymous users? [Y/n] Y
    Disallow root login remotely? [Y/n] Y
    Remove test database and access to it? [Y/n] Y
    Reload privilege tables now? [Y/n] Y

    Then log into the MariaDB console and create a database for NextCloud:

    mysql -u root -p

    Enter your MariaDB root password and press Enter. After you have entered your database, you need to create a database for NextCloud:

    MariaDB [(none)]> CREATE DATABASE nextclouddb;

    Then create a new database user and grant the appropriate rights to the database user over the database you created.

    MariaDB [(none)]> GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextclouddb'@'localhost' IDENTIFIED BY 'password';

    Then run the following command to immediately apply changes to database privileges:

    MariaDB [(none)]> FLUSH PRIVILEGES;

    Next exit Mysql with the following command:

    MariaDB [(none)]> q

    Install NextCloud

    You can download the latest version of NextCloud from the URL

    Otherwise, run the following command to download it using the terminal:


    After the download is complete, unzip the downloaded file using the following command:


    Then copy the extracted directory to the apache root web directory:

    sudo cp -ar nextcloud /var/www/html/

    Next, give the correct permission to the nextcloud directory:

    sudo chown -R www-data:www-data /var/www/html/nextcloud sudo chmod -R 755 /var/www/html/nextcloud

    Configure Apache for NextCloud

    Then you will need to create a virtual host file for NextCloud in the / etc / apache2 / sites-available directory /:

    sudo nano /etc/apache2/sites-available/nextcloud.conf

    Add the following lines:

    DocumentRoot "/var/www/html/nextcloud"
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    Options +FollowSymlinks
    AllowOverride All
    Dav off
    SetEnv HOME /var/www/html/nextcloud
    SetEnv HTTP_HOME /var/www/html/nextcloud
    Satisfy Any

    Save and close the file when done, then enable the virtual host with the following command:

    sudo a2ensite nextcloud.conf sudo systemctl restart apache2

    You also need to enable some Apache modules.:

    sudo a2enmod rewrite sudo a2enmod headers sudo a2enmod env sudo a2enmod mime sudo a2enmod dir

    Finally, restart the Apache service for the change to take effect.:

    sudo systemctl restart apache2

    Access NextCloud Web Setup Wizard

    Before accessing NextCloud, you need to enable port 80 through the UFW firewall. By default, UFW is disabled on your system, so you need to enable it first. You can enable it with the following command:

    sudo ufw enable

    Once the UFW firewall is turned on, you can enable port 80 by running the following command:

    sudo ufw allow80`

    Now you can check the status of the UFW firewall by running the following command:

    sudo ufw status

    After setting up your firewall, open a web browser and enter the URL You should see the page for creating an administrator account.

    Fill in all the details as shown below.:

    Username : nextcloudadmin Password : nextcloud@123

    Data folder : /var/www/html/nextcloud/data

    Database user : nextcloud Database password : password Database name : nextclouddb

    When done, click Finish to enter Nextcloud..


    Congratulations! You have successfully installed NextCloud on your Ubuntu 16.04 server. Now you can easily play with NextCloud, and also deploy it in your production environment. You can also explore the interface and additional features by installing plugins in the Nextcloud app store.