Learning by doing.

Setup Nextcloud

Jun 23, 2018 • Nextcloud • Tags: Nextcloud Linux


Nextcloud is a cloud service like Dropbox but runs on your own server with potentially much larger storage. If you have a Linux machine with internet access and large storage, it might be a good idea to setup Nextcloud to synchronize your files. In this post, we will build Nextcloud step by step.

LAMP configuration

This section is following this post with slight modification. First, install the LAMP server and stuff:

sudo apt-get install lamp-server
sudo apt-get install libxml2-dev php-zip php-dom php-xmlwriter php-xmlreader php-gd php-curl php-mbstring
a2enmod rewrite
sudo apt-get install mariadb-server

Creat nextcloud.conf under /etc/apache2/sites-available as 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


and then create a symlink

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

After that, configure Apache modules

sudo a2enmod headers
sudo a2enmod env
sudo a2enmod dir
sudo a2enmod mime
sudo service apache2 reload

Now configure MariaDB, first login MySQL as root

sudo mysql -u root -p


CREATE USER [email protected] IDENTIFIED BY ‘PASSWORD’; (Where PASSWORD is a password you want to use for the nextcloud database users)
GRANT ALL PRIVILEGES ON nextcloud.* TO [email protected];

Now the database is ready, let’s configure Nextcloud.

Nextcloud configuration

First, let’s download the zip file to your sever and unzip it to the right place

unzip -d /var/www/html/

Then one can access Nextcloud by the localhost IP, something like, and one will see a webpage of Nextcloud, in which an acount can be created, and the information of the database we just set should be typed in.

After that, one can download the macOS/Windows/iOS client and start using Nextcloud as a localhost service, but a true cloud service should be accessed externally.

Access externally/remotely

To access your own server externally/remotely, we need a DDNS service. I used No-IP. Just type in the DDNS information in your router. Then we need to configure Port Forwarding. For ssh, we need to forward the internal port 22, and for http we need port 80, while Nextcloud needs also 443.

After that, one need to modify /var/www/html/nextcloud/config/config.php and add a line about your DDNS domain information, something like

  array (
    0 => '',
    1 => '',

With those steps, Nextcloud is ready for external access.

Tags: Nextcloud Linux