Are you interested in having your very own Dropbox like service setup. Then you have come to the right place. A little while ago I came across an opensource application known as “OwnCloud.” OwnCloud provides very similar functionality to the likes of services like ‘Dropbox’ or ‘Google Drive,’ that allow users to backup their files and sync them across multiple devices. With  OwnCloud we will setup our own ‘Dropbox’ like service  and also be able to provide some functionality in addition to what we get from the typical public services.

OwnCloud is not a very complex application, but has all the components of a typical 3 -tier application namely Web Front End, Application Layer and Database. In order to deploy the application I utilized 2 Cloud  instances running Ubuntu and 1 Relational Database Service  instance. The following diagram depicts the application deployment architecture:

ca1-2
OwnCloud Application Architecture

The following details the application layout details:

  • Application: OwnCloud 8.1
    • Database: MySQL 5.6 running on a Relational Database Service by my cloud provider
    • Application + Web Server: Ubuntu 14.04 (Cloud Instance 1)
    • External Storage: Ubuntu 14.04 – sftp (Cloud Instance 2)

Application Deployment

The application deployment was a simple process. I followed the following steps in order to deploy OwnCloud on the Cloud:

Setting up the Database

Please note that I deployed this application using a Public Cloud Provider that provided me the Relational Database Service and a web interface to create the database and the user. But since different people will use different environments, I will not discuss specifics related to one cloud provider. Rather I will list down the steps and you should use your tools to configure the following:

  • Make sure you have MySQL installed and accessible from Cloud-Instance-1
  • Create a database.
    • If you are using command line tools  to connect to the database you can run the following commands from a mysql client to connect:
      $ mysql -h <IP/DNSName of Database> -u <DBAdminUser> -p
    • On the mysql> prompt run the following to create the owncloud user, db and grant the privileges. Replate password with your own password:
      CREATE USER 'owncloud'@'localhost' IDENTIFIED BY 'password';
      CREATE DATABASE owncloud; 
      GRANT ALL PRIVILEGES ON owncloud.* TO 'owncloud'@'localhost' IDENTIFIED BY 'password'; 
      GRANT ALL PRIVILEGES ON owncloud.* TO 'owncloud'@'%' IDENTIFIED BY 'password'; 
      FLUSH PRIVILEGES;
      exit;

      If you are using a manually installed database on Ubuntu make sure to edit the file : /etc/mysql/mysql.conf.d/mysqld.cnf and comment out bind-address = 127.0.0.1.  This will allow your database to listen on all interfaces to enable remote connections.

      $ sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf
         # bind-address = 127.0.0.1
      $ sudo service mysql restart

Deploying the OwnCloud application

Installation

The second step in setting up OwnCloud is installing the application itself. I followed the following steps to deploy the OwnCloud on Cloud instance 1:

  • Login in to the command line for Ubuntu on Instance 1:
     $ ssh root@<Cloud-Instance1>
  • Once logged in I downloaded the Release Key for OwnCloud software and add it to the apt-key repository:
     $ cd /tmp
     $ wget http://download.opensuse.org/repositories/isv:ownCloud:community/xUbuntu_14.04/Release.key
     $ sudo apt-key add - < Release.key 
  • Add the OwnCloud repository source to Ubuntu:
     $ sudo sh -c "echo 'deb http://download.opensuse.org/repositories/isv:/ownCloud:/community/xUbuntu_14.04/ /' >> /etc/apt/sources.list.d/owncloud.list"
  • Update the software repository:
     $ sudo apt-get update
  • Install the OwnCloud application
     $ sudo apt-get install owncloud

Make sure that the application installs successfully.

Configuration

Once the application is installed, we can proceed to the initial setup. Before the initial configuration make sure that you have connectivity to the owncloud database from the Cloud Instance 1.

On the Cloud-Instance 1 run the following command:

 $ mysql -h <IP/DNSnameOfDatabaseInstance> -P 3306 -u owncloud -p
 # When prompted enter the password set up in the RDS portal.
 
 # On the mysql> prompt I ran the following commands to ensure connectivity to the database:
 mysql> use owncloud;
 Reading table information for completion of table and column names 
 You can turn off this feature to get a quicker startup with -A 
 
 Database changed 
 mysql> exit 
 Bye
  • Now I went to my browser and opened the following URL:

   http://<Cloud-Instance1-IP>/owncloud/ca1-3

  • I clicked on the Storage and Database section and selected the MySQL-MariaDB  this opened up the configuration for the database.ca1-4
  • I used the following values to perform the initial configuration after which I clicked Finish Setup
Field Value
Username oadmin
Password  <NewApplicationAdminPassword>
Data Folder /var/www/owncloud/data
Configure the database MySQL-MariaDB
DB Username owncloud
DB Password  <owncloudDBPassword>
Database Name owncloud
Database Server <IP/DNS name for the Database Instance>

Using the OwnCloud application

Once I completed the initial configuration I was presented with the OwnCloud dashboard:CA1-5.png

This is a simple view of the files available on my cloud storage for the oadmin account.
In order to start using the application I decided to create another user. Note that oadmin is an administrative user.

Creating a new user

In order to create a new user I followed the following steps:

  • Click on oadmin (username on the top right) and select Users.
  • Enter username: appadmin password: and click Create.      

CA1-6.png

  • Since I wanted to create a normal user with no administrative rights I decided to leave the Groups and Group Admin settings to no group.

Now in order to see the application in action I decided to install an OwnCloud client on my desktop.

Installing the OwnCloud Desktop client

I am running a Fedora 25 Desktop. I followed the following procedure to deploy the agent on my desktop:

  • I ran the following command to add the owncloud client repository:
     $ sudo dnf config-manager --add-repo http://download.opensuse.org/repositories/isv:ownCloud:desktop/Fedora_25/isv:ownCloud:desktop.repo
  • And the following command  to install the client:
     $ sudo dnf install owncloud-client

Once the installation is complete I launched the OwnCloud desktop client in Fedora. This then takes you through the connection and account setup. I used the following values for configuring the OwnCloud Desktop Client:

Field Value
Server Address http://<CLoud-Instance1-IP>
Username appuser
Password <appsuserPassword>
Server Sync everything from server
Local Folder /home/noor/owncloud

At this point it provided me with an option of opening the ownCloud in Browser or the local folder. I chose the local folder and in a few seconds the default files/folders from the server were synced to my desktop:

ca1-7

If you are interested in other platforms the downloads can be accessed at:

https://owncloud.org/install/#

Adding External Storage to OwnCloud

In its current configuration OwnCloud was putting all the user files in /var/www/owncloud/data folder on the Cloud-Instance 1.

In order to make things more interesting I wanted to attach an external storage to the application that I could then expose to the application users. For this purpose I decided to run a ftp service on Cloud instance 2 and then make this FTP visible to the users with various options. I followed the following steps to set this up:

On the Cloud-Instance 2:

  • Added a user to the server for owncloud:
     $ sudo adduser owncloud

    Enter the password details and leave the rest as default

  • Create storage folders for shared storage and private user storage
     $ sudo su - owncloud
     $ mkdir /home/owncloud/owncloudstorage
     $ mkdir /home/owncloud/oadmin
     $ mkdir /home/owncloud/appuser

Since secure shell (ssh) was already installed on the Ubuntu servers in my Cloud the sftp service was available by default. The remaining configuration was done in the Administrative web interface. I followed these steps:

  • Go to http://<Cloud-Instance1-IP>/owncloud/
  • Login using oadmin credentials
  • Click on oadmin (username) on the top right corner and click Admin
  • On the Top left corner click on Admin and click the + App sign.
  • In the menu click on Not Enabled
  • Find External Storage Support and press the Enable button
  • Click on oadmin (username) on the top right corner and click Admin
  • Click on External Storage
  • Click the Add Storage dropdown and select sftp
  • Enter the following details:
    • Host: <Cloud-Instance2-IP>
    • Username: owncloud
    • Password: <owncloudPasswordAsOnCloudInstance2>
    • Remote subfolder: /home/owncloud/owncloudstorage
  • Click the Add Storage dropdown and select sftp
  • Enter the following details:
    • Host: <Cloud-Instance2-IP>
    • Username: owncloud
    • Password: <owncloudPasswordAsOnCloudInstance2>
    • Remote subfolder: /home/owncloud/appuser
    • Available for: appuser
  • Click the Add Storage dropdown and select sftp
  • Enter the following details:
    • Host: <Cloud-Instance2-IP>
    • Username: owncloud
    • Password: <owncloudPasswordAsOnCloudInstance2>
    • Remote subfolder: /home/owncloud/oadmin
    • Available for: oadmin

The following should be the result. Make sure all the storage attachments are green as shown below:

CA1-8.pngIf you now login in to the ownCloud dashboard for oadmin it will be similar to the following:

ca1-9

The dashboard for appuser will show a similar structure. However do note that the MyFTP folder for each user is a private folder only visible to that user. The SharedFTP folder is a shared folder and is visible to all users. If users upload any files on these folders these are now stored on the Cloud – Instance 2.

Once again I thank you for reading and your patience. If you have any questions/comments/issues please feel free to share below in the comments section so everyone from different sources can benefit from the discussion or drop me a word just so that I know you were here. Don’t forget to follow the blog.

For my latest posts please visit WhatCloud.

The Logo at the top is a registered logo for OwnCloud.

Advertisements