Install and Configure OwnCloud on Ubuntu 16.04

Table of Contents


OwnCloud is open-source software that enables you to create your own file sharing server, similar to Dropbox. Using OwnCloud you can easily view and sync calendar events, tasks, address books, and bookmarks. You can access OwnCloud using a nice looking web interface or install the OwnCloud client on a desktop machine. OwnCloud supports implementing user and group access restrictions on files.

In this tutorial, we will install and configure an OwnCloud server on using Ubuntu 16.04.


  • A server running Ubuntu 16.04.
  • A non-root user with sudo privileges enabled on your server.

Install LAMP Server

Before installing OwnCloud, you will need to update the OS and install the LAMP stack on your system.

You can do this by just running the following command:

sudo apt-get update -y
sudo apt-get upgrade -y
sudo apt-get install Apache2 mysql-server php libapache2-mod-php php-mcrypt php-mysql -y

Once installation is complete, start the Apache and Mysql services and enable them to start on boot:

sudo systemctl start apache2
sudo systemctl start mysql
sudo systemctl enable apache2
sudo systemctl enable mysql

You will also need to enable the rewrite module in Apache.

sudo a2enmod rewrite
sudo systemctl restart apache2

You will also need to secure Mysql, because the default configuration is not secure for production environments.

You can do this by running the following script:

sudo mysql_secure_installation

After running the above script, you will need to change the root password, disable and remove anonymous users from MySQL server, turn off the MySQL root user login remotely, delete the test database, and reload privilege tables on the system. Once you are finished your Mysql installation should be secure.

Install OwnCloud

By default an OwnCloud package does not exist in Ubuntu's standard repositories. So, you need to download their release key and import it with the apt-key command:

curl https://download.owncloud.org/download/repositories/stable/Ubuntu_16.04/Release.key | sudo apt-key add -

Next, create a repository address in the source directory for apt:

sudo nano /etc/apt/sources.list.d/owncloud.list

Add the following line:

deb http://download.owncloud.org/download/repositories/stable/Ubuntu_16.04/ /

Save the file and update the repository:

sudo apt-get update -y

Finally, install OwnCloud using the following command:

sudo apt-get install owncloud

Once installation is complete, you will need to restart the Apache server to apply the changes:

sudo systemctl restart apache2

Configure Database

You will also need to create a mysql database and user account for configuring OwnCloud.

Run the following set of commands to login to mysql server and create a database and user.

mysql -u root -p
Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.13-0ubuntu0.16.04.2 (Ubuntu)
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> CREATE DATABASE owncloud;
Query OK, 1 row affected (0.00 sec)
mysql> GRANT ALL ON owncloud.* to 'owncloud'@'localhost' IDENTIFIED BY 'password';
Query OK, 0 rows affected, 1 warning (0.00 sec)
Mysql> flush privileges;

Create SSL Certificate to Secure OwnCloud

Next, you will need to create SSL certificate to secure your OwnCloud server.

Run the following command to create the SSL certificate :

sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/owncloud.key -out /etc/ssl/certs/owncloud.crt

You should see the following output:

Generating a 2048 bit RSA private key
writing new private key to '/etc/ssl/private/owncloud.key'
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
Country Name (2 letter code) [AU]:IN
State or Province Name (full name) [Some-State]:GUJARAT
Locality Name (eg, city) []:JUNAGADH
Organization Name (eg, company) [Internet Widgits Pty Ltd]:ProfitBricks
Organizational Unit Name (eg, section) []:IT
Common Name (e.g. server FQDN or YOUR name) []:HITESH
Email Address []:hitjethva@gmail.com

Once the SSL certificate is generated, create an Apache SSL virtual host entry for OwnCloud.

You can do this by editing the default-ssl.conf file:

sudo nano /etc/apache2/sites-available/default-ssl.conf

Delete all the lines and add the following content:

<IfModule mod_ssl.c>
    <VirtualHost _default_:443>
            ServerAdmin your_email_address@domain.tld
            ServerName your_server_ip_address
            DocumentRoot /var/www/owncloud
            ErrorLog ${APACHE_LOG_DIR}/error.log
            CustomLog ${APACHE_LOG_DIR}/access.log combined
            SSLEngine on
            SSLCertificateFile      /etc/ssl/certs/owncloud.crt
            SSLCertificateKeyFile /etc/ssl/private/owncloud.key
            <FilesMatch "\.(cgi|shtml|phtml|php)$">
                            SSLOptions +StdEnvVars
            <Directory /usr/lib/cgi-bin>
                            SSLOptions +StdEnvVars
            BrowserMatch "MSIE [2-6]" \
                           nokeepalive ssl-unclean-shutdown \
                           downgrade-1.0 force-response-1.0

Save the file and restart Apache to apply the changes.

sudo systemctl restart apache2

Configure OwnCloud

Once everything is up-to-date, it's time to access the OwnCloud web interface.

Open your favorite web browser and type the URL https://your-server-ip/owncloud, you should see the following page:

OwnCloud Login Page

Next, enter a username and password to create an administrator account for OwnCloud, click on the Storage and Database, also provide the username and password for the MySQL database which you created in the previous steps.

Once you have entered the configuration information, click on the Finish Setup button. Once the configuration is completed, you should see a welcome splash screen as shown below:

OwnCloud home page


Congratulations! You have successfully installed OwnCloud with SSL support. Feel free to comment below or open a discussion in the Community section if you have any questions.

  • Thanks so much for the great walk through - everything worked as expected bar one bit:

    I had to run a2enmod ssl to get Apache to listen in on 443

  • Had to run this at the very end after getting this error in firefox on https://localhost and https://localhost/owncloud (in browser on the server): ssl_error_rx_record_too_long

    command: sudo a2ensite default-ssl

  • Thanks for provide best solution,now looking here the all solution,i hope you try to understand this process where are scanned documents windows 10 here the available simple tips to solve this issue,so following this simple tips.

Log In, Add a Comment