How to Install Nextcloud on Ubuntu 16.04

r00t August 8, 2017

Install Nextcloud on Ubuntu 16.04

In this tutorial we’ll learn how to install NextCloud on Ubuntu 16.04. We will also install and configure its prerequisites. NextCloud is a platform for collaboratively sharing files, documents, calendars and contacts between devices and individuals. With NextCloud installed, you can replace Dropbox and Google services with those you host yourself, respecting the autonomy and privacy of your data. NextCloud works with all major operating systems and mobile platforms. NextCloud provides user friendly web interface, so you can easily access your files through web browser from public and private network or from any device.

I recommend to use a minimal Ubuntu server setup as a basis for the tutorial, that can be a virtual or a root server image with an Ubuntu 16.04 minimal install from a web hosting company or you use our minimal server tutorial to install a server from scratch.

Install Nextcloud on Ubuntu 16.04

Step 1. First, ensure your system and apt package lists are fully up-to-date by running the following:

apt-get update -y && apt-get upgrade -y

Step 2. Installing LAMP on Ubuntu 16.04.

You should check out this LAMP stack install tutorial for Ubuntu 16.04, if you haven’t installed LAMP yet. Once it’s installed, come back here and read on. We also will install the required packages for LAMP stack and the important PHP extension that NextCloud relies on:

apt-get install php7.0-mysql php7.0-curl php7.0-json php7.0-cgi php7.0 libapache2-mod-php7.0 php7.0-mcrypt php7.0-gd php7.0-mbstring php7.0-zip php7.0-dom php7.0-xml

Step 3. Installing NextCloud.

NextCloud offers you the zipped archives for server admins to download and manually set it up on top of LAMP:

tar -jxvf nextcloud-*.bz2
sudo mv nextcloud /var/www/html/
sudo mkdir /var/www/html/nextcloud/data

Next, give proper permission to nextcloud directory:

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

Step 4. Configure Database for NextCloud.

Next, we need to create a database for the Nextcloud installation:

mysql -uroot -p

Run the following command to create a database for NextCloud:

MariaDB [(none)]> CREATE DATABASE nextcloud;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextcloud'@'localhost' IDENTIFIED BY 'strong_password';
MariaDB [(none)]> \q

Step 5. Configure Apache for NextCloud.

Next, you will need to create a virtual host file for NextCloud:

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

Add the following lines:

<VirtualHost *:80>
DocumentRoot "/var/www/html/nextcloud/"
<Directory "/var/www/html/nextcloud/">
Options FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
ErrorLog /var/log/apache2/
CustomLog /var/log/apache2/ common

Once done it’s time to enable the new site and enable apache mods that are needed by NextCloud:

a2ensite nextcloud
a2enmod rewrite headers env dir mime
systemctl restart apache2

Step 6. Accessing NextCloud Web Installation.

Now you can access the Nextcloud web install wizard in your browser by entering the domain name or http://your_ip/nextcloud/ to continue your Nextcloud installation.

Congratulation’s! You have successfully configured NextCloud on your Ubuntu 16.04 LTS server.


The Tags:

Leave a Comment

Comments are closed.