How to Install and Implement Owncloud on Ubuntu 14.04LTS

Dropbox, Google Drive, OneDrive, Box.com, and soon iCloud Drive…….These services all have one basic common feature: they run a service on your computer, and allow you to sync anything in a given folder (or folders) to a server(s) in the “cloud”, and other computers.

Sure, there are various differences. Google Drive and OneDrive allow you to edit files in some capacity. Dropbox is the big dog, having been around the longest (as far as I know). they also enjoy a lot of connectivity with third party apps, particularly on iOS and Android. That brings up another point; they’ve all got mobile clients, on iOS, Android, and sometimes even Blackberry and Windows Phone 8.

And soon, Apple is joining the fray with iCloud Drive, which on OS X Yosemite, will be directly integrated into Finder, and on iOS, and will also have a Windows client as well.

So what does this have to do with Owncloud? Owncloud does much of its competitors, however it has a distinct advantage: you host it on your server, therefore you control it, and the space is as unlimited as the space you own yourself. It’s also relatively easy to configure, as I’ll go through here.

There are drawbacks. For example, your constrained by your own bandwidth of your ISP’s connection. If you have a bandwidth cap, you’ve got to be careful with the amount of data you sync. And you also most definitely need to pay attention to the security of your network.

All in all though, Owncloud is an excellent package with a lively community on forum.owncloud.org. The feature set most definitely rivals Dropbox and the others, and it’s also nice to check your sync client and see that the sky’s the limit in terms of space. Well, your hard drive’s the limit. 🙂

This article assumes you’re relatively comfortable with installing operating systems, and using SSH on a computer, either through Linux, OS X, or using something like Putty on Windows. Being comfortable with some form of Unix text editing is important too, such as VI, emacs, or Nano (the latter of which I generally use).

First things first: Install Ubuntu 14.04LTS

The first thing you need to do is install Ubuntu 14.04LTS. This version is long term supported until April 2019, so anything you build now will enjoy patching for quite some time. You can get Ubuntu 14.04LTS here.

While there’s also a desktop version which will run Owncloud just fine as well, I’m going to focus on the more stripped down server version primarily.

Installing it is pretty straightforward, so I’m not going to cover it here. Plus, there’s plenty of documentation for that all over the web and at Ubuntu’s own site here.

One thing note during installation is that I do select the SSH and LAMP server configurations, as it makes it easier and saves a couple steps later. If you’re doing this is on a virtual machine as I’ve done, it also makes it easier to get right into the server through SSH. Make sure you remember the root password for MySQL, because you’ll need that for adding the database for Owncloud. Do not make it the same as your login password.

Screen Shot 2014-06-11 at 4.24.20 PM

 

Following installing, go ahead and do a sudo apt-get update, then sudo apt-get upgrade, and accept all patches. There shouldn’t be too many for 14.04LTS, but that should be done first.

UPDATE – You’re definitely going to want to do the MySQL security configuration, because it just goes the extra length in making your MySQL installation a little bit more secure. Go into a terminal window, and paste:

sudo mysql_secure_installation

This will then ask a series of questions, such as if you’d like to disable anonymous users (yes!), remove test database (yes!), and disallow remote login (definitely). It doesn’t make it fool-proof, but every little bit helps, you know?

Installing Owncloud

First thing to note is that there are a couple different ways to install Owncloud; you can install from their repositories (my personal favorite) or you can install manually by uploading it to your /var/www folder and configuring from there. I dig the automatic way, because it also updates automatically too.

So you’ll need to go here to add their repositories and key. One thing to note though, is that you’ll want to add the repository key after you add the repository, but before you do an apt-get update, then apt-get install owncloud. So do the following steps:

  1. sudo sh -c "echo 'deb http://download.opensuse.org/repositories/isv:/ownCloud:/community/xUbuntu_14.04/ /' >> /etc/apt/sources.list.d/owncloud.list"
  2. wget http://download.opensuse.org/repositories/isv:ownCloud:community/xUbuntu_14.04/Release.key
    sudo apt-key add - < Release.key
  3. sudo apt-get update
  4. sudo apt-get install owncloud

That way, when you do the update, it doesn’t give you any key errors. NOTE: A lot of this is easier if you do it by SSHing into your server, instead of running off of the command line directly, or via an ESX client. Copying and pasting is so much easier this way!

Configuring Apache for Owncloud

There are a few minor things you need to do, in order to get your server’s Apache install ready for Owncloud.

Run the following commands:

  1. sudo a2enmod ssl
    sudo a2ensite default-ssl
    sudo a2enmod rewrite
  2. Generate your certificates. I followed the excellent instructions here. make note of the default server root, if you don’t want to have to put /owncloud at the end of your URL, i.e. servername.com/owncloud.
  3. Restart your Apache server by typing
    sudo service apache2 restart

At this point, you can point your browser to the IP address of your server, and it should give you the following:

Screen Shot 2014-06-18 at 3.54.04 PM

But stop there; you don’t want to configure your admin account yet. First, it is most definitely recommended to move the data directory for your Owncloud server outside of the Apache root, which is /var/www. I’d recommend just creating something at the root of your drive (or another partition, if you have one), such as /ocdata. It really doesn’t matter what you call it, as long as you put it into the configuration set-up. You’ll also want to give the web user and group ownership of that directory, by typing “sudo chown -R www-data:www-data /ocdata”.

Next, you’ll need to edit the Apache configuration file to allow Owncloud to override the .htaccess file with it’s own.

  1. sudo nano /etc/apache2/apache2.conf
  2. Find “AllowOverride None” for /var/www and replace it with “AllowOverride All”
  3. Save the configuration file
  4. Give the web user and group ownership of the owncloud install directory by typing sudo chown -R www-data:www-data /var/www/owncloud

From here, you can finish the Owncloud configuration by going back to your server in a browser, and filling in the information:

Screen Shot 2014-06-18 at 4.03.08 PM

You can name the database whatever you want, it doesn’t matter. Make sure you clear out the data path, and put the path in for the directory you created. MySQL host is “localhost”, unless of course you’ve decided to host the MySQL database on a different server, which is totally fine. You’re not done yet, but you’re getting closer!

The last step is to change the PHP configuration to allow large file uploads. By default, it’s only 2MB, which is probably too small for pretty much anyone. However, you can easily change this by editing the PHP config file:

  1. sudo nano /etc/php5/apache2/php.ini
  2. Find “upload_max_size” and change it to something like 8G (8 gigabytes).
  3. Find “post_max_size” and change it to 8G as well.
  4. Find “output_buffering” and change it to 8192 (8GB in megabytes)
  5. sudo service apache2 restart

Now you can go into the Owncloud administration panel, located at the top right, and you will now see the following:

Screen Shot 2014-06-18 at 4.19.49 PM

Save that, and now you’re free to drag and drop large files. NOTE: I’ve not had much luck with files above 4GB in the web interface, but up to 8GB seems to work just fine in either the Owncloud sync client or a webDAV client like Cyberduck. It seems to time out. There’s probably a fix, but honestly, the times I’ve needed to upload a single file bigger than 4GB through the web interface is pretty much nonexistent.

That’s basically it. You’ve got your own cloud server, complete with web page uploads, as well as great clients for OS X, Windows, Linux, iOS, and Android. The sync clients are free on the desktop, but on mobile (on iOS at least; I don’t know about Android) it’s .99 cents. Well worth it though, since you can upload photos and videos directly from your phone, which is fantastic. You can also share links to files as well, directly from the mobile client. Very cool.

Posted in Tech, Uncategorized.