Skip to content

How-To Install ownCloud 9 / 9.1 / 9.x on Ubuntu 16.04 LTS for the ULTIMATE, Private, Dropbox Clone



Let’s face it, since the advent of Dropbox, Box, Google Drive and the bazillion other cloud-based file synchronization platforms that have came into existence over the past decade, it’s almost a necessity. For the road warrior, using multiple devices, or even the traditional white-collar worker, having access to all of your files no matter what device you’re using is extremely convenient and adds an enormous productivity boost to our lives. One of my biggest concerns with all of the third-party services, however, is privacy and security. Allowing another entity to store my sensitive data, and trusting they will keep in secure, is pretty scary. Thankfully, there are many options to roll-your-own cloud file synchronization and it really doesn’t take much horsepower on the server side. With a low cost VPS (virtual private server), retired computer at home, or even a $25 RaspberryPi, you can easily build your own Dropbox clone that will put you in control of your own data. Today, I’ll walk you through setting up ownCloud 9.1 on Cannocial’s Ubuntu 16.04 LTS. I will be setting up my cloud on a virtual machine running on VMware ESXi, but the process is very similar no matter what hardware platform you choose. This step-by-step guide assumes you have a plain, unmodified, minimum installation of Ubuntu Server 16.04 LTS, with only SSH access. If you don’t have SSH running, or don’t want to enable it, console access will work just fine. So, lets get started!


Installing Prerequisites (Apache/MySQL/PHP)


Go ahead and login to your freshly installed Ubuntu 16.04 server.  Be sure to login with a username that has sudoer privileges.  This can be the username you selected during installation or specified when you provisioned your VPS.  Let’s make sure everything is up-to-date before going any further. We will use Aptitude to do so.


#  sudo apt-get update

#  sudo apt-get upgrade -y


Now we can jump in to the nitty gritty.  There are a few standard prerequisites needed for ownCloud to run.  Most people refer to this as the LAMP stack (short for Linux, Apache, MySQL, PHP).

So, here is what we will actually install:

  • Web Server – Apache 2
  • Database Server – MySQL
  • Scripting Language – PHP

It’s all pretty simple and straight forward to setup.  We’ll start with Apache.  Lets start the install using Aptitude.


#  sudo apt-get install apache2 -y


To make sure everything installed properly and is functioning, we will use the apache2ctl command.


#  sudo apache2ctl configtest


You should see something like this.


Syntax OK


If you open a browser, you can now browse to the default hello world page included with Apache by default.  Simply browse to http://youripaddress/ (or, if you already have a domain name pointed to your server’s IP address,  It should look like this.




Now, if you didn’t see that page load, and Apache installed without any errors in the previous step, chances are you are entering the wrong IP address, or the default firewall, UFW, is blocking port 80.  In order for Apache to work properly, and in turn ownCloud, you need two ports opened for inbound and outbound traffic. Ports 80 (http) and 443 (https).  Lets make sure those ports are open using the ufw command.


#  sudo ufw app list


You should get a list of open ports. In my case I have Apache and OpenSSH Server running, so I have for applications listed; Apache (port 80), Apache Full (ports 80 & 443), Apache Secure (port 443) and OpenSSH (port 22).


Available applications:
  Apache Full
  Apache Secure

If you’re unable to browse to the Apache default html page and those applications are not showing via ufw, you’ll need to make sure they are opened up and allowed for inbound and outbound traffic. If all is good, let’s continue by installing out database server, MySQL. To do so, once again we will use Aptitude.

#  sudo apt-get install mysql-server -y


During the installation process, you’re going to be presented with a pretty pink screen, prompting you to set a password for the MySQL root user password.  This is not the linux root account, this is just the database’s root account.  Make sure it’s secure, and don’t forget it!




Now that we’ve installed MySQL, let’s clean up some of the default garbage that’s included.   This will increase security.  There is a command to do just that.


#  sudo mysql_secure_installation


You will need to enter the MySQL “root” password you just set on the pink screen. Next, you’ll be asked if you want to configure the VALIDATE PASSWORD PLUGIN.  This plugin will force secure passwords for anything having to do with the database, and can be pretty inconvenient.  If you are capable of setting secure passwords on your own, I suggest selecting “N” (or anything but “Y) and not configuring this option.  For the remaining four questions, select “Y” for each of them.  Here is a screenshot for reference.




The only step left before moving on to ownCloud is PHP. This is easy and we will use Aptitude to install it, as well as a few PHP modules that are needed for MySQL and Apache to talk to eachother, which is necessary for ownCloud to function.


#  sudo apt-get install php libapache2-mod-php php-mcrypt php-mysql php-cli -y


Let’s go ahead and restart Apache and make sure it loads up.  If you get a warning about a global name not being specified, you can safely ignore it for now.


#  sudo systemctl restart apache2


Before we move on to the good stuff, lets make sure PHP is working properly.  We will create a very simple web page that will display PHP information.  Nano is the text editor we will use to create the file.  It’s extremely easy to use.  All you need to know is to exit, you will hit Ctrl-X, then hit enter to save and exit.  Let’s create our simple PHP page.


#  sudo nano /var/www/html/info.php


Enter the following two lines into the text editor, the select Ctrl-X, Enter, to save and exit.




That’s it. Now, to test everything out, fire up a web browser, and go to http://youripaddress/info.php You should see a page with a bunch of information about your PHP installation. It should look like this.




Now that we’ve verified everything is ready for ownCloud, lets delete that file since we don’t need it anymore.


#  sudo rm /var/www/html/info.php


Installing OwnCloud 9.x


To make installation, and future upgrades, as painless and easy as possible, we will use Apititude to install OwnCloud.  In order to do so, we have to add the OwnCloud Repo to Aptitudes sources directory.  To do that, we will first download and import the GPG key, then we will add the repo.  Do the following.


#  curl | sudo apt-key add -

#  echo 'deb /' | sudo tee /etc/apt/sources.list.d/owncloud.list




Now that the new source repo has been added, we need to update Aptitude to make it aware of the OwnCloud packages which are available for installation.


#  sudo apt-get update


At last, we can actually install OwnCloud with a single command!!


#  sudo apt-get install owncloud -y


Because OwnCloud automatically adds a configuration file to Apache, we need to restart Apache before creating a database and browsing to our new OwnCloud installation.


#  sudo systemctl restart apache2


OwnCloud Database Configuration


Before we can tell OwnCloud what database it needs to use, we need to create one.  MySQL includes a nifty utility to do just that.  Remember to use the MySQL root password you specified on the pink screen when prompted.


#  mysql -u root -p


Now you are logged into the MySQL console.  This is where you create databases and assign permissions to them.  Many books have been written on this utility, so I’ll just help you get the minimum done.  First, create our new database for OwnCloud.  All commands in the MySQL console must end with a semicolon (;) as shown below.


mysql>  CREATE DATABASE owncloud;


Now we need to assign permissions to the newly created database.  Remember to change ‘set_database_password’ to a password you remember.  You will need this when we configure OwnCloud to use this database.  This should not be the same as your system root account, or your MySQL root account, for obvious security reasons.


mysql>  GRANT ALL ON owncloud.* to 'owncloud'@'localhost' IDENTIFIED BY 'set_database_password';


Now that permissions have been set, we can flush out any stale information and exit.



mysql>  exit


It should look something like this.




Now that your back at the command line, lets go and and knock out one last item.  Best security practices for ownCloud mandate that you shouldn’t have your ownCloud data folder (which your personal files are stored) in a public web accessible directory, which is is by default.  So, lets create a data directory that is one level up from the public html directory.  Then, we will change it’s owner and group to www-data, which is needed for Apache/ownCloud to read, write and modify the directory.  This is very easy.


#  sudo mkdir /var/www/ocdata

#  sudo chown www-data /var/www/ocdata

#  sudo chgrp www-data /var/www/ocdata


Enough of the command line stuff, now we get use a GUI!

ownCloud Configuration


To configure ownCloud, we will use the web interface.  So, go ahead and open up a web browser and point it to http://server_ip_address/owncloud You should see a web page like this.




This is where you create an admin account and configure basic settings for ownCloud.  You will need to click on “Storage & database” to expand those fields to enter the database data.  So, here is a rundown on the information you need to enter here.

  • Username – Enter a username for the administrative account (not an account for your daily use and not named admin).
  • Password – Enter a strong password, but not one used in any previous steps.
  • Data Folder – (Expand Storage & database to see this field) This is the folder we just created. /var/www/ocdata
  • Configure the database – MySQL/MariaDB.
  • Databse Name – owncloud
  • Database Password – The password you entered in place of ‘set_database_password’ in the MySQL console.
  • Database Username – owncloud, unless you changed it earlier.
  • Database Server – This last field is the database server, and since it’s hosted locally in our case, leave it set to localhost.

Here is a screenshot of the info above, entered in my configuration screen.




Once you have all of the correct info entered, click Finish setup, and you’ll be logged into your new ownCloud server!




Now is a good time to go ahead and create a username for your daily use and add it to the admin group (click the icon in the top right and select Users, the rest is pretty self explanatory).

That’s it!  Go ahead and install the client on your PC or iDevice and get to syncing.  If you are going to use this long term, or in a production environment, I suggest installing an SSL certificate and only using HTTPS (SSL) so all traffic is encrypted.  Fortunately, with this setup and LetsEncrypt, that doesn’t cost a yearly fee for a certificate anymore, it’s free now!  Stay tuned for my next guide on securing Apache by installing a free SSL certificate from LetsEncrypt, with automatic renewal!  Thanks for reading and please feel free to post any questions in the comments below. If you get stuck, there are many frequent visitors that would be happy to help, myself included!

One thought on “How-To Install ownCloud 9 / 9.1 / 9.x on Ubuntu 16.04 LTS for the ULTIMATE, Private, Dropbox Clone

  1. Jonathan Iphone says:

    Good morning,

    Thank you so much for this great tutorial that helped me so much and sorry for my bad English.

    I was able to install everything without problem.

    I wonder how do you access it remotely? When I’m not at home, is there a solution? At the moment I can just access it with http://localhost/owncloud

    Thank you.


Leave a Reply