Personal Drive with OwnCloud

With Raspberry pi on hand, I was always wondering if there is any way to setup my own drive that could provide common services, if not identical, as the Google Drive or similar. Therefore, in this edition of my notebook, I am writing step by step process on installing Owncloud in local server. The following post on notebook will also summarizes;

  • Setting up Owncloud on local server
  • Setting up internet access to your drive
  • Encrypting network connection with SSL, and
  • Setting up Owncloud on android.

OwnCloud is a open source server platform, that provides file sharing, cloud data management, and collaboration tool environment . Once setup, files can be accessed, shared, and manage from any device with internet connection.

Hence, by the end this notebook series, what you will have is your own drive that is accessible from any part of the world via internet through a smartphone app or browser, given that a few conditions are met.

Alright, let get started!

To set the OwnCloud to local server, we need to have few prerequisite i.e.

  • any local server; Apache in our case
  • php on top of Apache
  • any database server; MySQL in our case

Installing Apache

# Apache installation
sudo apt-get install apache2

# start apache2 
sudo systemclt start apache2

# check status and make sure its running
sudo systemctl status apache2.service

# enable service on boot
sudo systemctl enable apache2

# allow port to pass firewall (not required in most case)
# http - 80
# https -443 (ssl encrypted)
sudo ufw allow 80/tcp 
sudo ufw allow 443/tcp

# reload firewall
sudo ufw reload
sudo ufw status

# Finally apache setup is done

After installation, open any browser type http://127.0.0.1 or http://localhost or http://your_hostname.local. Your installation is correct if you see the similar page.

Fig; Apache web server screen

Installing PHP

# check for available php version
sudo apt-cache policy php

# install php
sudo apt-get install php php-cgi libapache2-mod-php php-common php-pear php-mbstring php-mysql php-curl php-json

Installing MySQL

# Check for available mysql version
sudo apt-cache policy php

# install mysql
sudo apt-get install mysql-server mysql-client

# secure mysql installation
sudo mysql_secure_installation

With this you should see number of installation prompt , type ‘y’ for yes and continue with it.

Installing OwnCloud

# download owncloud
sudo wget https://download.owncloud.org/community/owncloud-10.4.1.zip

#unzip the package
sudo unzip owncloud-10.4.1.zip -d /var/www

Configure Apache for OwnCloud

We need to create a new configuration file for owncloud setup as follow in the /etc/apache2/conf-available/owncloud-conf

# sudo nano /etc/apache2/conf-available/owncloud-conf

Alias /owncloud "/var/www/owncloud/"

<Directory /var/www/owncloud/>
  Options +FollowSymlinks
  AllowOverride All

 <IfModule mod_dav.c>
  Dav off
 </IfModule>

 SetEnv HOME /var/www/owncloud
 SetEnv HTTP_HOME /var/www/owncloud

</Directory>

Save and exit the nano editor, and enable the modules with the following command.

sudo a2enconf owncloud
sudo a2enmod rewrite
sudo a2enmod headers
sudo a2enmod env
sudo a2enmod dir
sudo a2enmod mime

Restart apache server and access the owncloud http://localhost/owncloud

# restart apache server
sudo systemctl restart apache2

Configure OwnCloud

Once you access the main page you should see the following page at initial access:

So create:

  • admin username and password
  • give data folder location at Data folder
  • provide database user, password an database name you created during the mysql setting
  • and click finish setup to complete the process