Installing NextCloud

Download the NextCloud server zip archive onto your server. The latest version is 10.0.0 at the time of this writing. You may need to change the version number. Go to https://nextcloud.com/install and click the download button to check out the latest version.

wget https://download.nextcloud.com/server/releases/nextcloud-13.0.5.zip

Install unzip utility:

sudo apt install unzip

Now extract NextCloud by:

unzip nextcloud-13.0.5.zip

By unzipping the downloaded file a new directory named nextcloud will be created in the current working directory. Copy the new directory and all of its content to the document root of Apache server.

sudo cp -r nextcloud /var/www/

After copying you can remove the downloaded and extracted files in the working directory. As a standard the working directory is located in var/www/nextcloud directory what is not advisable. Beter is to relocate the data directory to a larger harddisk in the system. This will be used later.

Set up correct rights to the directories:

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

Create a Database and User in MariaDB

The passwoord setup does only work if you are root. Use the password you created during installation of the LAMP-stack. Log into MariaDB database server with the following command:

sudo mysql -u root -p

Then create a database for Nextcloud. This tutorial name the database nextcloud. You can use whatever name you like. Let op het ; teken aan het einde van de commandos!

create database nextcloud;

Create the database user. Again, you can use your preferred name for this user. Replace your-password with your preferred password.

CREATE USER ncroot@localhost IDENTIFIED BY ‘password’;

The single colons above around the password are required.

Grant this user all privileges on the nextcloud database.

grant all privileges on nextcloud.* to ncroot@localhost identified by ‘password’;

Flush privileges and exit.

FLUSH PRIVILEGES;
exit;

Enable Binary Logging in MariaDB

Edit the mysqld configuration file.

sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf

Add the following three lines in [mysqld] section.

#
# Added for installation of NextCloud
#
log-bin        = /var/log/mysql/mariadb-bin
log-bin-index  = /var/log/mysql/mariadb-bin.index
binlog_format  = mixed

The format of binary log must be mixed. Save and close the file. Then reload MariaDB service.

sudo systemctl restart mariadb

Now binary log is enabled in MariaDB.

Create an Apache Virtual Host File for Nextcloud

We will create a nextcloud.conf in /etc/apache2/sites-available directory.

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

Copy and paste the following lines in the file. Replace the red text with your actual domain name. You also need to point your domain name to the IP address of your Ubuntu server in DNS.

Alias /nextcloud "/var/www/nextcloud/"
<VirtualHost *:80>
DocumentRoot "/var/www/nextcloud"
ServerName nextcloud

<IfModule mod_headers.c>
    Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains"
</IfModule>

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

<Directory /var/www/nextcloud/>
Options +FollowSymlinks
AllowOverride All
<IfModule mod_dav.c>
    Dav off
</IfModule>

SetEnv HOME /var/www/nextcloud
SetEnv HTTP_HOME /var/www/nextcloud
Satisfy Any

</Directory>
</VirtualHost>

Save and close the file. Then create a symbolic link to /etc/apache2/sites-enabled/

sudo ln -s /etc/apache2/sites-available/nextcloud.conf /etc/apache2/sites-enabled/nextcloud.conf

Enable the following Apache modules. Je zal er verschillende vinden die al zijn aangezet, dit is om zeker te weten dat ze aan staan.

sudo a2enmod rewrite
sudo a2enmod headers
sudo a2enmod env
sudo a2enmod dir
sudo a2enmod mime
sudo a2enmod setenvif
sudo a2enmod ssl
sudo a2ensite default-ssl

Restart Apache so that the above Apache and PHP modules are loaded.

sudo systemctl restart apache2

Finish the Installation in your Web Browser

Now in your web browser, type your domain name. For instance

192.168.1.100/nextcloud
A dialog in your webbrowser comes up. Answer the questions and make sure you fill in the corrrect data directory.

Last Updated on 30 september 2018