With the recent fork of the Owncloud project, many users are switching over to the newly founded Nextcloud project to build and use their own personal cloud servers to host personal files, photos, movies, and documents. This alternative is popular for people concerned with data privacy, as you do not need to rely on a public cloud or drive similar to Box, Dropbox, Google Drive, OneDrive, etc. With those services, you don’t know precisely where your data lives, who has access to view it, and what safeguards are in place to protect your data. With Nextcloud, you know exactly where your data resides, and who has access to it. Best of all, running it on a Debian or Ubuntu ARM server is easy! Let’s get started!
In this tutorial, we will show you how to install Nexcloud on an Ubuntu or Debian ARM server.
First, let’s update the server to the latest versions of applications:
sudo apt-get update
sudo apt-get upgrade
sudo reboot
Next, we need to install the core applications that will make Nextcloud work; PHP, Apache, and MySQL. You will be asked to create a MySQL root password during this installation:
apt-get install lamp-server^
apt-get install libxml2-dev php-zip php-dom php-xmlwriter php-xmlreader php-gd php-curl php-mbstring
a2enmod rewrite
sudo service apache2 reload
Once that is complete, it is time to actually download and configure Nextcloud (version 10 is the latest at the time of this writing, but check to see if a newer version exists and replace the number in these commands):
wget https://download.nextcloud.com/server/releases/nextcloud-10.0.1.tar.bz2
tar -vxjf nextcloud-10.0.1.tar.bz2
sudo mv nextcloud /var/www
Next, we need to set the proper permissions on the Nextcloud files and folders. Nextcloud has provided a script that will do this for us, making it very easy. Thus, we need to create a new file and paste in the contents of the script they’ve given us.
nano nextcloud_permissions.sh
Paste this in to the new file:
#!/bin/bash
ocpath=’/var/www/nextcloud’
htuser=’www-data’
htgroup=’www-data’
rootuser=’root’
printf “Creating possible missing Directories\n”
mkdir -p $ocpath/data
mkdir -p $ocpath/assets
mkdir -p $ocpath/updater
printf “chmod Files and Directories\n”
find ${ocpath}/ -type f -print0 | xargs -0 chmod 0640
find ${ocpath}/ -type d -print0 | xargs -0 chmod 0750
printf “chown Directories\n”
chown -R ${rootuser}:${htgroup} ${ocpath}/
chown -R ${htuser}:${htgroup} ${ocpath}/apps/
chown -R ${htuser}:${htgroup} ${ocpath}/assets/
chown -R ${htuser}:${htgroup} ${ocpath}/config/
chown -R ${htuser}:${htgroup} ${ocpath}/data/
chown -R ${htuser}:${htgroup} ${ocpath}/themes/
chown -R ${htuser}:${htgroup} ${ocpath}/updater/
chmod +x ${ocpath}/occ
printf “chmod/chown .htaccess\n”
if [ -f ${ocpath}/.htaccess ]
then
chmod 0644 ${ocpath}/.htaccess
chown ${rootuser}:${htgroup} ${ocpath}/.htaccess
fi
if [ -f ${ocpath}/data/.htaccess ]
then
chmod 0644 ${ocpath}/data/.htaccess
chown ${rootuser}:${htgroup} ${ocpath}/data/.htaccess
fi
Now we will just make the script executable, and then run it:
sudo chmod +x nextcloud_permissions.sh
sudo ./nextcloud_permissions.sh
Our next step is to configure Apache to listen for and serve requests for the NextCloud application. We will create an Apache configuration file to accomplish this, and then populate it:
nano /etc/apache2/sites-available/nextcloud.conf
Paste this Apache configuration in to the file:
Alias /nextcloud "/var/www/nextcloud/"
<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
</Directory>
Next, we are going to make some changes to the Apache modules that are loaded and then restart Apache:
sudo ln -s /etc/apache2/sites-available/nextcloud.conf /etc/apache2/sites-enabled/nextcloud.conf
sudo a2enmod headers
sudo a2enmod env
sudo a2enmod dir
sudo a2enmod mime
sudo a2enmod ssl
sudo a2ensite default-ssl
sudo service apache2 reload
Now it is time to configure MySQL by creating the table and user that Nextcloud needs to operate. First we connect to MySQL:
sudo mysql -u root -p
Once logged in to MySQL, we”ll make the table and user:
create database nextcloud;
create user nextclouduser@localhost identified by 'your-password';
grant all privileges on nextcloud.* to nextclouduser@localhost identified by 'your-password';
flush privileges;
exit;
At this point, we decided a reboot was probably a good idea, but you might be able to skip this step:
sudo reboot
Once your server comes back up, the Nextcloud web interface will be available, and we will finish our configuration via the browser. In your browser, go to http://[the-ip-address-of-your-server]/nextcloud
You will see the “Create Account” screen shown here:

You will need to create an Admin name and password for your Nextcloud install, and when you scroll down you will notice that Nextcloud needs the MySQL information you created earlier. Provide it the information asked, if you used the instructions above, the database name is ‘nextcloud’, username is ‘nextclouduser’, and then whatever password you selected. The location of the database is ‘localhost’.
If everything is correct, you will be redirected to the Dashboard (you will get an inline pop-up to download the Nextcloud Apps first)

Dismiss that and you will see the Files application:

At this point, you are up and running with Nextcloud on your Ubuntu or Debian ARM Server! You can even add additional features and applications from the menu, such as Mail, Document viewer, Tasks, and more! Happy hosting!
