How to install Nextcloud 18 on Ubuntu Server

Installing a powerful on-premises cloud solution can be done in just a few minutes with Nextcloud 18.

How to install Nextcloud 18 on Ubuntu Server

The Nextcloud cloud server is often considered one of the best solutions for any sized business looking for an on-premises solution. Nextcloud is reliable, easy to use, extendable, offers an outstanding mobile app, is open source, and free.

And with the latest iteration comes some serious improvements. The addition of the built-in OnlyOffice suite alone makes Nextcloud 18 a must-have for so many. The cherry on top of that cloud-based office suite is new features like Workflow and Analytics. Simply put, Nextcloud 18 cannot be beat.

But how do you install it? I'm going to walk you through the process.

SEE: Serverless computing: A guide for IT leaders (TechRepublic Premium)

What you'll need

I'll be demonstrating on the Ubuntu Server 18.04 platform, so the only things you'll need are:

  • A running, updated instance of Ubuntu Server 18.04

  • A user with sudo privileges

How to install necessary dependencies

The first thing to be done is the installation of the necessary dependencies. Log in to your Ubuntu Server and install the web and database servers with the following command:

sudo apt-get install apache2 mysql-server -y

Next, install the remaining dependencies with the command:

sudo apt-get install php zip libapache2-mod-php php-gd php-json php-mysql php-curl php-mbstring php-intl php-imagick php-xml php-zip php-mysql -y

How to set up and configure the database

The installation of MySQL doesn't include the creation of an admin password. To take care of that, issue the command:

sudo mysql_secure_installation

Once you've completed the database configuration, it's time to create the necessary database. Log in to the MySQL prompt with the command:

sudo mysql -u root -p

At the prompt, create the database with the command:


Next, create a user and give the user the proper permissions with the commands:

CREATE USER 'nextcloud'@'localhost' IDENTIFIED BY 'PASSWORD';
GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextcloud'@'localhost';

Where PASSWORD is a strong, unique password.

Finalize the database with the commands:


How to download and unpack Nextcloud

Now it's time to download the latest Nextcloud 18 file. To download this file, issue the command:


Unzip that file with the command:

unzip nextcloud*.zip

Move that file into the proper directory with the command:

sudo mv nextcloud /var/www/html/

Finally, give the newly moved directory the correct ownership with the command:

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

How to configure the web server

Next we're going to configure the web server. Create a new Apache configuration file with the command:

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

In that new file, paste the following:

Alias /nextcloud "/var/www/html/nextcloud/"
<Directory /var/www/html/nextcloud/>
    Options +FollowSymlinks
    AllowOverride All
      <IfModule mod_dav.c>
        Dav off
     SetEnv HOME /var/www/html/nextcloud
    SetEnv HTTP_HOME /var/www/html/nextcloud

Save and close the file.

Enable the new site and the necessary modules with the commands:

sudo a2ensite nextcloud
sudo a2enmod rewrite headers env dir mime

PHP requires a tweak to the default memory limit. Do that with the command:

sudo sed -i '/^memory_limit =/s/=.*/= 512M/' /etc/php/7.2/apache2/php.ini

Restart Apache with the command:

sudo systemctl restart apache2

How to finalize the installation

You are now ready to complete the installation. Open a browser and point it to http://SERVER_IP/nextcloud (where SERVER_IP is the IP address of your hosting server). You'll be greeted by a page (Figure A) where you must create an admin account and enter the details for the database.

Figure A


The web-based installer.

The database details are as follows:

  • Database user - nextcloud

  • Database password - the password you created at the MySQL prompt

  • Database name - nextcloud

Click Finish Setup and the installation will complete. You can then log in with the admin account you created and start using one of the finest on-premises cloud server solutions on the market.

Also see


Image: Jack Wallen