Do you want the convenience of an omnipresent Dropbox-like storage service without doling out wads of cash and your data to a third party? OwnCloud is one of the best pieces of opensource software to help you create your own private and protected cloud-sharing service.
Using OwnCloud, you can sync and share your private data, and access it from any device connected to the internet. For added security, OwnCloud can also encrypt your files. The software can handle files in a variety of formats and you can extend its usability by adding a number of other apps.
As with other online cloud storage services, you can sync files on OwnCloud either using the web browser or a desktop client on Windows, Mac and Linux, as well as mobile clients for Android and iOS devices. Furthermore, your OwnCloud server keeps older versions of all changed files and enables you to revert to an older version without much effort.
1. Lay the groundwork
In this tutorial, we’re setting up the OwnCloud server on top of the Raspbian distribution for the Raspberry Pi. The server software has modest requirements and it performs well, even on the Raspberry Pi Model B, in certain small and controlled environments, such as your house.
You also need a USB portable disk for storing the data. For maximum reliability and performance, it’s best to use a self-powered disk that doesn’t draw power from the Raspberry Pi. Before you begin setting up the server, make sure the Raspberry Pi has a static IP address.
The easiest way to do this is to tie an IP address to your Raspberry Pi’s unique MAC address in your router’s admin page. Here, we’re assuming the Raspberry Pi is at 192.168.3.111 – change as appropriate.
2. Install OwnCloud
Raspbian is based on the Debian OS, so we can pull in packages from OwnCloud’s Debian repository. Fire up a terminal and add the OwnCloud repositories with:
$ wget http://download.opensuse.org/repositories/
$ sudo apt-key add – Release.key
You can now refresh the repositories with:
$ sudo apt-get update
Now install the OwnCloud server and all its required dependencies as follows:
$ sudo apt-get install owncloud.
This also pulls in and sets up the MySQL database, and you’re asked to set up a root password.
In addition to installing the required components, the above command automatically confi gures the Apache web server to talk to the OwnCloud installation. You need to enable certain Apache modules. In a terminal, enter:
$ sudo a2enmod headers rewrite env
Then restart Apache using:
$ sudo apachectl restart.
You have to tweak the configuration file of PHP if you wish to upload fi les that are greater than 2MB in size. To do that, open the PHP configuration file, ‘php.ini’, housed under ‘/etc/php5/apache2’, in a text editor. Look for the ‘upload_max_fi lesize’ and ‘post_max_size variables’ and change their value from ‘2M’ to something like ‘1024M’ or even ‘2G’.
Optionally, on larger installations, you can also install the APC PHP accelerator to make the OwnCloud installation snappier. Pull in the components with “sudo apt-get install php-apc” and then open APC’s configuration file and add:
$ sudo nano /etc/php5/conf.d/20-apc.ini
extension=apc.so apc.enabled=1 apc.shm_size=12M
Then bring the cache online by restarting Apache with:
$ sudo apachectl restart
3. Mount the drive
Now that the server is set up and configured, it’s time to prepare the storage medium. Plug the USB disk into the Raspberry Pi and enter “sudo blkid” in a terminal. The USB disk is probably mounted as ‘/dev/sda1’ if you don’t have any other USB disks attached.
Make a note of the corresponding UUID, which looks something like ‘6154-F660’. Now create a directory to mount this drive using:
$ sudo mkdir /media/owncloud
Then mount the drive with:
$ sudo mount -t vfat -o umask=007,auto,uid=33,gid=33 /
The above command assumes your drive has a FAT32 filesystem and is mounted at ‘/dev/sda1’. Once the drive is mounted correctly, you can edit the ‘fstab’ file to make sure it’s automatically mounted:
$ sudo nano /etc/fstab
UUID=6154-F660 /media/owncloud/ vfat
rw,umask=007,auto,uid=33,gid=33 0 0
4. Configure the cloud
That’s all there is to installing the server components. You’re now all set to configure your cloud. Launch a web browser and navigate to the OwnCloud installation instance at ‘192.168.3.111/owncloud’. Because this is a brand new installation, you’re asked to create a new user account for the OwnCloud administrator.
Next, we need to ask OwnCloud to use the MySQL database and store files under the mounted USB drive. For this, click the ‘Storage & Database’ pull-down menu. Then enter “/media/ owncloud/data” in the text box corresponding to the ‘Data Folder’ entry and select the ‘MySQL/MariaDB’ option in the ‘Database’ section.
You’re asked to enter the connection details of the database server, so just enter “localhost” as the host and “root” as the username, along with the password you configured when the database was pulled in along with OwnCloud.
That’s it – you’ve set up OwnCloud. You can now log into your cloud server as the administrator using the credentials you’ve just created.
5. Change settings
While you can start using the server to upload and download files straight away, let’s take a moment to get your house in order. For starters, when you log into the OwnCloud server, click the pull-down menu next to your username and click ‘Personal’.
Here you can change the settings for your account, such as the login password and display name. You can also add a profile picture and configure how you’d like to be notified about certain actions.
Also, if your cloud is going to be used by multiple people, it’s advisable to add users and organise them into different groups. To do this, select the ‘Users’ option from the pull-down menu. While adding users, you can restrict their storage space and even share your admin responsibilities with other users, and mark certain users as admins for a particular group.
6. Upload and share files
You’re now all set to upload data into your OwnCloud server. After you’ve logged in, you are in the ‘Files’ section. To upload a file, click the arrow button.
To organise files into folders, click the button labelled ‘New’, and select the ‘Folder’ option from the drop-down menu to create a new folder.
If you’ve uploaded a file in a format that OwnCloud understands, you can click its name to view and edit the file.
OwnCloud can visualise the data it houses in different views. For example, click the ‘Files’ pull-down menu in the top-left corner of the interface, and select ‘Pictures’. This helps you view images in your cloud by filtering out all other types of content.
Another way to upload files to the server is by using the WebDAV protocol, with which you can access your cloud server from your file manager. For example, in the ‘Files’ file manager, press [Ctrl]–[L] to enable the location area. Here you can point to your OwnCloud server, such as ‘dav://192.168.3.111/owncloud/remote.php/webdav’.
Once authenticated, the OwnCloud storage is mounted and you can interact with it just like a regular folder.
To share uploaded files, simply go to the ‘Files’ section in the web interface and hover over the file or folder you wish to share. This displays several options, including ‘Share’, which enables you to select which users or groups you want to share the item with and whether you want to give them permission to edit and delete the files.
You can also share with someone who isn’t registered with your OwnCloud server. Click on ‘Share with Link’, and OwnCloud displays a link to the item that you can share with anybody on the internet. You can also password-protect the link and set an expiration date too.
While you can interact with the cloud using the web interface, it’s far easier to use one of its official clients. OwnCloud has clients for all the major desktop and mobile platforms. These clients also help you synchronise folders from the desktop to your OwnCloud server with ease.
7. Set up clients
Most desktop distributions host the Linux client in their official repos. You can also grab the latest version by adding the corresponding repo for your distro. The page has instructions for popular distros including Debian, Fedora, Ubuntu, OpenSUSE and more.
Once the client is installed, it prompts you for your login credentials in order to connect to the OwnCloud installation. Once connected, the Linux clients create a local sync folder named ‘owncloud’ under the home directory, such as ‘/home/bodhi/owncloud’.
Any files you move into this directory are automatically synced to the server. You can also specify one or more directories on a local machine to sync with the OwnCloud server.
If a directory is shared with several users, when anyone makes a change to a file on one computer, it automatically flows across to the others. When collaborating with other users, you’ll appreciate OwnCloud’s version control system, which creates backups of files before modifying them.
These backups are accessible via the Versions pull-down option corresponding to each file, along with a Restore button to revert to an older version.
In addition to files and folders, you can also get your calendar and address book synced with your OwnCloud server.
8. Install and enable apps
You can extend your default OwnCloud installation by adding (or removing) a bunch of apps. Bring up the pull-down menu in the top-left of the interface and click ‘Apps’.
By default, you’re shown a list of apps that are already enabled on your installation. You can browse through this list and read their descriptions to understand them better. You can also disable any enabled app from this section.
Scroll down and click the ‘PIM’ tab on the left. This section lists two apps. You can enable either or both the Calendar and Contacts apps. Once you’ve enabled both, the top-left pull-down menu now includes the Calendar and Contacts option.
Now you need to import your contacts and calendar from your existing apps into your cloud server. OwnCloud supports the popular vCard file format (which has the .vcf file extension) and almost every popular email app, including online ones such as Gmail, export their address books in this format.
Similarly, calendars can be imported in the iCal format. Before proceeding further, make sure you download both the .vcf and .ical files from your existing contacts and calendar apps.
Now, head to Contacts in OwnCloud and click ‘Import Contacts’. In the pop-up window, click ‘Upload File’ and point it to the .vcf file. Once the contacts have been imported, you can sync them with your email clients using CardDAV links. Head to the ‘Contacts’ section in OwnCloud, click the gears icon at the bottom, hover over the name of the address book you imported and click the ‘Chain’ icon.
This spits out a CardDAV link for this address book that you can feed to your desktop or mobile address book client.
9. Sync and share your calendar
Similarly, you can use OwnCloud to manage your calendar and tasks. To create an event in your calendar, head over to the Calendar app. You can view the calendar for the entire month or for the current week.
To add a new event, click the appropriate date in the calendar. This brings up a window, which gives you several options to configure the event. To import an existing client, simply upload the .ical file to your cloud server. When you click the file in OwnCloud’s web interface, the server recognises the file and offers to import it into an existing calendar or into a new one. Select the option that best suits you.
After you’ve imported the calendar, you can use OwnCloud to share it with other users. Click the ‘Share Calendar’ icon corresponding to the calendar you wish to share. This brings up a pull-down menu, which enables you to select the users or the group of users you wish to share the calendar with.
Furthermore, just like address books, OwnCloud can also sync your calendars with desktop and mobile apps that can read this information from CalDAV links. To get the CalDAV link for your calendar, click the ‘Gears’ button and then the ‘Chain’ icon corresponding to the calendar you wish to sync.
This displays the link that you can pass on to the clients to keep them in sync with the OwnCloud calendar.
There’s a lot more you can do with OwnCloud. Explore the ‘Apps’ menus to find other ways to flesh out the default installation and extend the functionality of your cloud. In addition to the apps listed in the Apps section on your OwnCloud installation, there are others that you can install from the OwnCloud website.
Scroll down the Apps section and click the ‘More Apps…’ link. This takes you to the OwnCloud store. You can download any app from here and extract it under the ‘/var/www/owncloud/apps’ folder inside the Raspberry Pi.
10. Universal access
The real advantage of commercial cloud services such as Dropbox is that you can access data stored within them from any computer connected to the internet.
However, by default, a self-hosted OwnCloud installation is only accessible from computers and devices that are within the local network.
That’s not to say that you can’t access your private cloud from the internet. The trickier and expensive solution is to get a static IP address from your ISP and then poke holes in your router’s firewall.
Or, you can set up Dynamic DNS in your router or local machine. The smarter way, however, is to use a tunnelling service, such as PageKite. The service uses a pay-what-you-want model. As a non-commercial user, you can use the service for free by filling out a form once a month, telling PageKite how you use the service.
But if that sounds like too much hassle, it’s definitely worth the $3 per month minimum it requests from individuals.
First, you need to install PageKite. Launch a terminal and enter:
$ curl -s https://pagekite.net/pk/ | sudo
When it’s done, make your local web server public by entering the following command:
$ pagekite.py 80 mycloudserver.
Also, remember to replace ‘mycloudserver’ with the name you want for your OwnCloud server. Now you can access your own personal OwnCloud instance by heading over to http://mycloudserver.pagekite.me from any computer, anywhere in the world.
The first time you run this command, PageKite runs you through its brief signup process and will ask you for your email address.