Step-by-step guide to deploy Nextcloud on DreamCompute

This article explains how to install Nextcloud on two DreamCompute instances. One instance is for  the application itself and the other instance for the database it uses.

Launch an instance

First, launch two Ubuntu 16.04 LTS instances. View the following category of articles for different ways to do this:

Use a volume based instance

It is recommended to boot a volume backed instance as they are permanent as opposed to ephemeral disks and can be larger than 80GB in size if larger amounts of data will be stored. This can be done in the DreamCompute dashboard or with the OpenStack command line client.

Add a security group

Once you have those instances up and running, you need to add a security group to the instance that runs the database so it allows TCP on port 3306, the MySQL/MariaDB port. View the following two articles for further instructions:

Installing MariaDB

In order to install MariaDB on your database server, first log into the server with with your username and the database server's public IP address:

[user@localhost]$ ssh

Next, switch to your root user:

[user@dbserver]$ sudo su - 

You must switch to the root user because you must have administrator rights to install things system-wide.

As your root user, install mariadb by running:

[root@dbserver]# apt update
[root@dbserver]# apt install mariadb-server

During installation the root database user will be set up without a password, but an authentication plugin will prevent login from anyone but the operating system root user. A password can be set if desired.

Configuring MariaDB

Changing the bind address

Edit the 50-server.cnf file located at /etc/mysql/mariadb.conf.d/50-server.cnf. It will show the following:

bind-address            =

Edit this to be:

bind-address            = $IP

where $IP is the IP address of the DB server.

If you have private networking enabled, this will be the private IP address and not the floating IP if your DB server has one.

This makes the database listen to connections from its IP address instead of only listening on (the localhost).

Allowing root login from a foreign IP address

The database will now listen to connections from other servers, but you must allow users to log in from another IP address. Do this by logging into the DB as root.

[root@dbserver]# mysql -u root

Then run the following commands to create a database named 'nextcloud'. Make sure to change $IP to the IP address of your application instance, and $PASSWORD to the password you want to set for the user of the database.

use mysql;
create database nextcloud;
GRANT ALL ON nextcloud.* TO nextcloud@'$IP' IDENTIFIED BY '$PASSWORD';
flush privileges;

If you want to allow root login from any IP address, you can change $IP to '%'. However this is not recommended, especially if your database server has a public IP address (because then anyone can try to access it).

Next, restart the mariadb service so the new configs are loaded by running:

[root@dbserver]# service mysql restart

Installing the Nextcloud application

Installing dependencies

You must now deploy the frontend application. First log into the server that you will be installing Nextcloud on. Once logged in, switch to the root shell again by running:

[user@webserver]$ sudo su - 

Then run the following commands to install Nextcloud and its dependencies.

[root@webserver]# apt update
[root@webserver]# apt-get install apache2 libapache2-mod-php7.0 unzip
[root@webserver]# apt-get install php7.0-gd php7.0-json php7.0-mysql php7.0-curl \
php7.0-mbstring php7.0-intl php7.0-mcrypt php-imagick php7.0-xml php7.0-zip

The backslash character \ is used when entering a long command. When you enter the \, the terminal command continues to the next line until you finish entering it.

You could also remove the \ character and put every parameter into a single line.

Downloading Nextcloud

You must now download the actual Nextcloud application.

  1. Navigate to in a browser.
  2. Right click the Download Nextcloud button, and click copy link address.
  3. In your root shell run the following (change the version to the link you just copied).
    [root@webserver]# wget
  4. This will download a compressed copy of the Nextcloud application.
  5. Decompress the file by running the following (change the version number to the version you're using).
    [root@webserver]# unzip
This creates a directory called 'nextcloud' in your current directory.

Setting up the nextcloud directory

You must now copy Nextcloud to the directory /var/www/nextcloud. Run the following:

[root@webserver]# cp -R nextcloud /var/www/

Change the permissions of the nextcloud directory so the web user, www-data in this case, can access it. Run the following:

[root@webserver]# chown -R www-data:www-data /var/www/nextcloud

Configuring Apache

You must now configure Apache to use Nextcloud. Create a file in the directory /etc/apache2/sites-available called 'nextcloud.conf'. Add the following contents to this file:

Alias /nextcloud "/var/www/nextcloud/"

<Directory /var/www/nextcloud/>
  Options +FollowSymlinks
  AllowOverride All

 <IfModule mod_dav.c>
  Dav off

 SetEnv HOME /var/www/nextcloud
 SetEnv HTTP_HOME /var/www/nextcloud


Next, symlink /etc/apache2/sites-enabled/nextcloud.conf to /etc/apache2/sites-available/nextcloud.conf by running the following:

[root@webserver]# ln -s /etc/apache2/sites-available/nextcloud.conf \

Nextcloud also needs certain apache modules to run properly. Enable them by running:

[root@webserver]# a2enmod rewrite

You should also use SSL with Nextcloud to protect login information and data. Apache installed on Ubuntu comes with a self-signed cert. To enable SSL using that certificate, run:

[root@webserver]# a2enmod ssl
[root@webserver]# a2ensite default-ssl
[root@webserver]# service apache2 restart

Finishing the Installation

Now that everything is configured on the server, open a browser and visit https://IP/nextcloud where IP is the IP address of your application instance.

Create an admin account using the web interface and fill in the details for the database.

  • The database user is 'nextcloud'
  • the password is the password you set up for that user
  • the host is the IP address of your database server
  • and the database name can be set to anything.

Click Finish Installation and you have a working installation of Nextcloud.

Did this article answer your questions?

Article last updated .