1. Code
  2. PHP

Introduction to OwnCloud Server: File Sharing Under Your Control

Read Time:8 minsLanguages:
Final product imageFinal product imageFinal product image
What You'll Be Creating

What's OwnCloud?

OwnCloud provides a free, open source file sharing and application server and platform with desktop and smartphone applications, allowing you to create a personal or corporate cloud under your own control. If you're a Dropbox user, then you're familiar with the advantages of a remote cloud which keeps files on all of your desktops and devices in sync and allows you to share them with other people. 

Dropbox has come under scrutiny for privacy and security issues as well as its controversial decision to appoint former Bush administration Secretary of State Condoleezza Rice to its Board of Directors. OwnCloud allows you to host and secure files on your own server, providing you increased control over your remote files.

There's even an app store to expand the capability of your OwnCloud. The apps include email clients, news readers, video streaming and more.

This is the first tutorial of a series I'll be focusing on with OwnCloud. I do participate in the discussions below. If you have a question or topic suggestion, please post a comment below. You can also reach me on Twitter @reifman or email me directly.

Who Built OwnCloud?

Open source developer Frank Karlitschek decided to build OwnCloud after giving a talk on data privacy, warning people about privacy with cloud vendors such as Dropbox:

So, build it yourself they said. Sure, I’ve built things in the past, so sure, I’ll do it. And there is where I started my odyssey, first, to protect myself, my friends and my colleagues from the snooping of governments, and other bad guys, and later – as I saw the worldwide interest grow – to build a real and successful project. —OwnCloud Founder Frank Karlitschek

He describes his thinking process more in a blog post: Why I Built OwnCloud and Made It Open Source.

Karlitschek intentionally used open source technologies so that the code "would be completely transparent (so unlikely to contain 'back doors' to my data)."

He also wanted to support application extensions to support a Google News type application, virus scanning and file logging.

What Languages Is It Built In?

Karlitschek said they "evaluated different options to find the right technology that runs on every relevant platform, scales from tiny servers to big clusters, has all the needed features and is known by a big number of developers. So we choose PHP and JS for the server part, C++ for the Desktop Syncing Clients, Objective-C for iOS and Java for Android."

Many years ago, I was part of a nonprofit building open source tools for other nonprofit organizations. I remember being disappointed when our Director of Technology chose Java for new versions of our technology instead of PHP, which is a much friendlier, accessible platform for our development community. The organization imploded soon after for unrelated reasons.

I appreciate that Karlitschek kept in mind the need to use a platform that a large community of developers could also engage with.

The OwnCloud Enterprise Edition

Like Automattic and WordPress, OwnCloud is backed by a for profit corporation offering a premium Enterprise edition for larger users. They offer a variety of datasheets if you wish to learn more.

Hosting OwnCloud

There are a number of options for hosting OwnCloud. You can do so on your own dedicated servers. You can install OwnCloud as an application on a virtual server at a hosting company such as Digital Ocean; I'll describe how to do this below. Or, you can subscribe to an OwnCloud service provider (ASP). Some of these even offer freemium plans—but be sure to evaluate the reputation, privacy and security provided by your ASP.

Another interesting option is offered by the folks at MacMiniColo. They published a guide to installing and administrating OwnCloud: Install Owncloud on a Mac mini server (Mac Mini Colo Blog). They provide a dedicated server hosting facility that allows you to ship them a user-configured MacMini or purchase one of theirs. 

Installing OwnCloud at Digital Ocean

You can install OwnCloud on your own server via their Download page. You can install from the code, or their web installer or pre-built packages. The latter is nice for easily maintaining OwnCloud with the latest updates and security packages.

For that reason, for this tutorial I'm going to show you how to install OwnCloud at Digital Ocean. If you've read some of my tutorials before, you know I'm a fan of theirs for a number of reasons. Digital Offers a variety of pre-configured applications as one-click installations, and OwnCloud is now one of them.

For this tutorial, I'm going to follow Digital Ocean's guide to using the OwnCloud one-click install; it's written by one of their great community managers, AndrewSB.

Getting Started

I'll assume you have a Digital Ocean account before proceeding, but if you'd like you can learn more about signing up or using Digital Ocean with WordPress here.

Create a Droplet

From the Digital Ocean dashboard, click the Create Droplet button and type in your desired hostname. I'm going to use Digital Ocean recommends having at least 1 GB memory which requires a $10 per month droplet.

OwnCloud Create Droplet at Digital OceanOwnCloud Create Droplet at Digital OceanOwnCloud Create Droplet at Digital Ocean

You can generally use the default region Digital Ocean recommends unless you need to be able to communicate on Digital Ocean's intranet with other droplets you have:

OwnCloud Select RegionOwnCloud Select RegionOwnCloud Select Region

Click on the Applications tab and click the ownCloud 8.x image button:

OwnCloud Select ownCloud ImageOwnCloud Select ownCloud ImageOwnCloud Select ownCloud Image

Submit the form and you should see the creating your droplet progress screen:

OwnCloud Creating Your DropletOwnCloud Creating Your DropletOwnCloud Creating Your Droplet

When it's complete, you'll see your droplet on the dashboard:

OwnCloud The Droplet in Your DashboardOwnCloud The Droplet in Your DashboardOwnCloud The Droplet in Your Dashboard

Now, configure your domain name DNS to point to the droplet, i.e. set an A record for the subdomain or domain name to the IP address:

OwnCloud Set Your DNS A RecordOwnCloud Set Your DNS A RecordOwnCloud Set Your DNS A Record

You'll also receive an email address with the password for the server:

OwnCloud Your Digital Ocean Email OwnCloud Your Digital Ocean Email OwnCloud Your Digital Ocean Email

Once your DNS changes propagate you can visit your site—but you'll get this warning. OwnCloud requires you to add this domain to its listed of trusted domains. 

OwnCloud Logging in the first timeOwnCloud Logging in the first timeOwnCloud Logging in the first time

When you click the grey button, you should see the general login screen:

Log In to Your OwnCloud Dashboard

However, you may have noticed we don't have our dashboard credentials yet:

OwnCloud LoginOwnCloud LoginOwnCloud Login

To obtain them, use the SSH login credentials and a terminal application to log in to your droplet server:

OwnCloud Use SSH to Login to Get Your Web Dashboard PasswordOwnCloud Use SSH to Login to Get Your Web Dashboard PasswordOwnCloud Use SSH to Login to Get Your Web Dashboard Password

You'll see the Dashboard credentials when you log in. Ubuntu will also request you set up a new root password.

Then, you can return to the browser and log in to your OwnCloud.

When I finally clicked that grey button regarding trusted domains, I ran into a problem; it gave me an error. But I was able to log in using my IP address in the browser bar. Here's the initial OwnCloud dashboard:

OwnCloud DashboardOwnCloud DashboardOwnCloud Dashboard

If you update the Apache site configuration files manually as described here, then this won't occur.

While I couldn't find the administrative area for setting a trusted domain, pasting in the earlier URL allowed me to do so.

Then I was able to log in with my domain name.

Enforcing HTTPS Access

The Digital Ocean OwnCloud image comes with a built-in SSL certificate. I recommend turning on Enforce HTTPS in the administration menu.

OwnCloud Security Enforce HTTPSOwnCloud Security Enforce HTTPSOwnCloud Security Enforce HTTPS

Then you can log in with HTTPS. However, the initial certificate is not validated with a third party authority:

OwnCloud HTTPS Certificate Not TrustedOwnCloud HTTPS Certificate Not TrustedOwnCloud HTTPS Certificate Not Trusted

Digital Ocean's guide to using the OwnCloud one-click install provides further instruction on purchasing a valid certificate and configuring it on your server. 

Encrypting Your Cloud Files

You can also enable the Encryption application which encrypts the storage stored on your Digital Ocean droplet. Click the Files dropdown and click + Apps:

OwnCloud Files Apps AddOwnCloud Files Apps AddOwnCloud Files Apps Add

Browse the Not enabled filter to Enable Server-side Encryption:

OwnCloud Apps Add Server-side EncryptionOwnCloud Apps Add Server-side EncryptionOwnCloud Apps Add Server-side Encryption

Click Enable to begin, and then log out and log in once more. Then the continuous encryption process of your cloud will begin.

Comparing Pricing

If you're an individual using Dropbox, it's free up to 2 GB. However, you can earn extra storage through referrals. My free account currently has 10 GB of storage. For $9.99 monthly, you can receive 1 TB per month. The business plan begins at $75 monthly for five users with unlimited storage.

Hosting at Digital Ocean does not offer comparable storage at these prices. The 1GB memory droplet at Digital Ocean includes a 30GB hard drive for about $10 monthly, but storage does not scale well with price. For example, an 80GB drive is $80 per month and a 640 GB drive is $640 per month, primarily because Digital Ocean exclusively uses fast SSD drives. 

Other hosting providers may offer more storage per dollar than Digital Ocean, but at slower access speeds.

What's Next?

In future posts, I plan to explore the desktop and smartphone applications for iOS and some of the OwnCloud app extensions such as Calendar and News. 

Please feel free to post your questions and comments below. You can also reach me on Twitter @reifman or email me directly. You can also browse my Tuts+ instructor page to see other tutorials I've written. 

Related Links

Looking for something to help kick start your next project?
Envato Market has a range of items for sale to help get you started.