Jump to content

How To: Self Host Your Own Cloud Storage With ownCloud

Introduction

 

Why am I hosting my own cloud storage solution?

Cloud Storage is a service that we are using more and more as each single day goes by. It is estimated that there is currently 1 exabyte (1 billion gigabytes) of data in cloud storage.  I also utilise cloud storage. However, I want more control, for two reasons. The first being the flexibility of the services, a lot of cloud storage services like Dropbox aren’t flexible. There are limits to how much data you can have and cost grows considerably when you need more storage, I’m also storing data on their servers rather than having it on one server or even being mirrored to multiple servers in different locations. The second reason, and I’ll keep this brief like I did with the first reason is privacy. My data is mine and nobody else’s. If I want someone else to look at it I will show them. While it is still likely that my traffic can be monitored, at least I have a bit more control in the matter.

 

Why am I using ownCloud?

When looking for a solution to use for I initially came across a whole bunch of different solutions, most of which I immediately dismissed as there were two clear options for me to choose from. The option I didn’t go with was BitTorrent Sync. While it is a nice solution, which is decentralised by design, I can have a central point which acts as a backup that is considerably less likely to fail than any of the systems I actually use.

 

However, I decided to use ownCloud. This solution is a high quality piece of server-side software built for a personal cloud storage solution. The client software will then integrate well into your Windows, Mac OS X or Linux desktop to allow easy syncing, editing and creation/deletion of files all around the systems. There are mobile applications but towards the end of the tutorial I will show you how you can take advantage of Google Drive (well Google Docs) to make file syncing a bit easier from an Android device.

 

Why am I using DigitalOcean as my VPS provider?

ownCloud is best used on a VPS, unless you have an ability to drop a server into a data centre or you buy from a service hosting ownCloud. There are many VPS provides around the world but my personal favourite is DigitalOcean. They provide high quality, fully open source powered VPS’ that can run many a whole bunch of different Linux server distributions and they even have images to get a distribution preconfigured with things such as WordPress or a LAMP stack.

 

My DigitalOcean VPS will be hosted in their London data centre which has only just opened up in the past week. They also have locations in Amsterdam, Singapore, San Francisco and New York. You can packages from as little as $5 a month and their prices do also scale up very well. But enough of me giving them free advertisements and on with the guide.

Link to comment
Share on other sites

Link to post
Share on other sites

Initial Server Setup

 

Updating Ubuntu Server

One you get into your VPS/Server, there are a few things we need to do before we proceed to setup ownCloud. Making sure your distribution is up to date is the first thing we need to do. I’m running Ubuntu 14.04 x64 so we need to run the following commands. Note this is currently being done as the root user. We will setup a user account afterwards:

apt-get update && apt-get upgrade

Setting Up A New User Account

Now we are going to add a user account. Run the command in the box below. You can change the part in red (the user name) to whatever you like. You will get asked to set a password but any other questions, like asking for your name, you can leave that blank.

adduser owncloud

Configuring Sudo

Now we are going to give our new user the permission to run as root, via sudo. Type in the following command:

visudo

You will now see a text editor window, hopefully nano, that has the configuration file for sudo. You will see a line of text slightly down the windows with the following lines:

# User privilege specificationroot    ALL=(ALL:ALL) ALL

We are now going to add a new line below the default root line to add our new user to the list of sudo-ers. Once you have added the file, close the file (usually control + x) and then we can proceed onto the next step.

# User privilege specificationroot    ALL=(ALL:ALL) ALLowncloud      ALL=(ALL:ALL) ALL

Configuring SSH

We are now going to configure SSH so we can log in via our new user account but also disable root login and change the port we connect by. Start by typing the following command while still on the root account.

nano /etc/ssh/sshd_config

The first option we are going to change is the port that SSH uses.  The line of text will currently look like this:

# What ports, IPs and protocols we listen forPort 22

I’m personally changing SSH to port 1000

# What ports, IPs and protocols we listen forPort 100

Now scroll down to a section in the file called Authentication. By default the section looks like this:

# Authentication:LoginGraceTime 120PermitRootLogin yesStrictModes yes

We have are no going to change it so it looks like this. This is for added security but to also make it so only the user that we will install the cloud software by can login. Save the file and then exit your text editor.

# Authentication:LoginGraceTime 120PermitRootLogin noStrictModes yesAllowUsers owncloud

We are then going to restart SSH by running the following command:

service ssh restart

Fail2Ban – Added System Security

We are now going to install Fail2Ban, a piece of server side software that will give us added security and will severely lower the chance of our server being brute forced. From now on we will be running as the user account we created rather than using the root account.

 

Installing Fail2Ban

We will install Fain2Ban by running the following command:

sudo apt-get install fail2ban

Changing the configuration

Now we need to open up the fail2ban configuration file in a text editor. I’m going to be using nano in this guide and it would be great if you did as well. We will be opening the file by running the following command:

sudo nano /etc/fail2ban/jail.conf

While there are many things we can change. There is only one thing that we really need to change. The default configuration does a good job of protecting your server from being brute forced into. However, it can also lock you out of your own server. If you are on a static IP address you can put yourself on a list of ignored IPs to prevent being locked out. This line of text is right at the start of the file and shouldn’t be too hard to miss. Leave a space after the IP that is already there, 127.0.0.1/8, and then write your IP. We can then save the file by pressing Control + X and then pressing y then enter.

 

We will now restart fail2ban by using the following command:

sudo service fail2ban restart

You can see the rules that fail2ban puts into the IP tables by typing the following command:

sudo iptables –L
Link to comment
Share on other sites

Link to post
Share on other sites

Installing ownCloud Server

 

Adding the Repository and Installing ownCloud
Now we are going to install ownCloud server onto our VPS. This stage should be fairly quick and will mainly revolve around us installing ownCloud and setting up a MySQL database for the software to use. The first part of installing ownCloud is adding the repository key to our system. You can do this by running the following commands:

wget http://download.opensuse.org/repositories/isv:ownCloud:community/xUbuntu_14.04/Release.keysudo apt-key add - < Release.key

We will then proceed to adding the repository and then installing ownCloud and MySQL. You can do this by running the following set of commands. Note that during the setup you will be asked to set a root password for the MySQL server.

sudo sh -c "echo 'deb http://download.opensuse.org/repositories/isv:/ownCloud:/community/xUbuntu_14.04/ /' >> /etc/apt/sources.list.d/owncloud.list"sudo apt-get updatesudo apt-get install owncloud mysql-server php5-intl php5-curl

MySQL Configuration
Now we will be configuring the MySQL server. This will allow ownCloud to have a more robust database than the default SQLite implementation. First we must configure MySQL by running the following commands:

sudo mysql_install_dbsudo mysql_secure_installation

Now we shall be adding a database for the ownCloud server to use. Use the following the commands. Change the 'select_database_password' with a password for your MySQL database.

mysql -u root -pCREATE DATABASE owncloud;GRANT ALL ON owncloud.* to 'owncloud'@'localhost' IDENTIFIED BY 'select_database_password';exit

Final ownCloud Setup
The final piece of setup now takes place in the web browser. Go into your browser… and yes you can use Internet Explorer. Type in the following into the address bar:
http://ip-address-of-server/owncloud
 
We are now going to be presented with this screen. Make sure you select MySQL for the database and if you followed the guide as written here then the information for the MySQL section will be identical. Set whatever username and password you like for using ownCloud.
LOEG4qf.png
 
Congratulations. You now have ownCloud installed and ready to go on your server. You will also be presented with a screen asking you to download desktop and mobile clients. It is best that you do that. Thank you for watching my guide and the next post will provide some more information on what you can do with ownCloud to make your personal computing experience, a little bit more personal.

Link to comment
Share on other sites

Link to post
Share on other sites

Preview and Document Editing Configuration

 

Since ownCloud 6, users have the ability to have good preview generation for files as well as the ability to do some basic editing to text document files. There is also the ability to do collaborative editing if you have multiple users using your instance of ownCloud or you are using it as part of a system provided by your place of work or education. We are also going to be setting up ffmpeg for streaming videos from your ownCloud server.

 

Installing Dependencies

To get the best experience within the basic editor and for previews to work well, there are a few dependencies needed in order to get things working correctly. We are going to be using ffmpeg for video streaming, ImageMagick for previews and LibreOffice for Word Document previews and to power the editor.

sudo apt-add-ppa ppa:jon-severinsson/ffmpegsudo apt-get update && sudo apt-get upgradesudo apt-get install libreoffice imagemagick ffmpeg

Changing Config.php

The Admin GUI within the ownCloud browser page will allow you to make enough changes to the configuration. However, we need to manually set the location for LibreOffice and also enable previews. Your config.php will look different to mine but I have put the lines I've added/changed into bold text so you can see what I have done.

cd /var/www/owncloud/configsudo nano ./config.php

This is what my config.php looks like at the moment

<?php$CONFIG = array (  'instanceid' => 'xxx',  'passwordsalt' => 'xxx',  'trusted_domains' =>  array (    0 => 'xxx',  ),  'datadirectory' => '/var/www/owncloud/data',  'dbtype' => 'mysql',  'version' => '7.0.0.8',  'dbname' => 'owncloud',  'dbhost' => 'localhost',  'dbtableprefix' => 'oc_',  'dbuser' => 'xxx',  'dbpassword' => 'xxx',  'installed' => true,  'loglevel' => '0',  'forcessl' => true,  'preview_libreoffice_path' => '/usr/bin/libreoffice',  'enable_previews' => true,  'preview_max_scale_factor' => 1,);

There are two other options that you can add that I haven't decided to use on my ownCloud installation. The first is known as Maximum Preview Size. You can set the value to null so there is no limit but if you have a lot of files, or you want to keep the previews smaller, you can limit the size of previews. Replace x with the values you want to set.

'preview_max_x' => x,'preview_max_y' => x,

 

The second value is Maximum Scale Factor. This will put a limit onto how much an image can be scaled. It is useful to limit this if you have a lot of small images that become stretched when you view them via ownCloud. You can leave the value at null to have no limit but a recommended value is 1.

'preview_max_scale_factor' => x,

A Quick Reboot

The easiest way for all the changes to take effect is to quickly reboot your server. It is recommended that you do this via the terminal. Some VPS providers give you an option to reboot via their Control Panel and if you are hosting it on a server that have physical access to then you can reboot via manually turning it off and then on again.

sudo reboot
Link to comment
Share on other sites

Link to post
Share on other sites

Is this a commercial? :lol:

 

This seems interesting, I'll follow and come back later when it's all posted up. :)

 

It is done now...

Link to comment
Share on other sites

Link to post
Share on other sites

Updated the guide with a section for setting up previews and getting the editor working.

Link to comment
Share on other sites

Link to post
Share on other sites

So this is applicable to a OwnCloud jail on FreeNAS, because I have been meaning to set one up for months...

Link to comment
Share on other sites

Link to post
Share on other sites

So this is applicable to a OwnCloud jail on FreeNAS, because I have been meaning to set one up for months...

 

I don't think so. FreeNAS is based off of FreeBSD (I believe) so the commands will be different.

Link to comment
Share on other sites

Link to post
Share on other sites

I don't think so. FreeNAS is based off of FreeBSD (I believe) so the commands will be different.

 

But isn't a Owncloud jail a Linux VM inside of the FreeNAS BSD-system ?

Link to comment
Share on other sites

Link to post
Share on other sites

But isn't a Owncloud jail a Linux VM inside of the FreeNAS BSD-system ?

 

I've never used an ownCloud Jail and thus I wouldn't actually know. I'm guessing it could be a Linux VM though.

Link to comment
Share on other sites

Link to post
Share on other sites

I don't think so. FreeNAS is based off of FreeBSD (I believe) so the commands will be different.

 

 

So this is applicable to a OwnCloud jail on FreeNAS, because I have been meaning to set one up for months...

I have been using ownCloud on Portjail on freeNAS for some time now . although I am not a FreeNAS expert but the guide i follow from the freenas forums is this one i mention below . Its not for novice users as the author expects you to know how to do the basic and intermediate level stuff but its the best guide for setting up Owncloud 7 on FreeNAS. 

 

http://forums.freenas.org/index.php?threads/how-to-owncloud-using-nginx-php-fpm-and-mysql.17786/

Link to comment
Share on other sites

Link to post
Share on other sites

This is some neat stuff you posted here. I may as well learn how to do this now so I can get a cheaper rate on storage and have features that won't cost me a fortune in the long run.

Link to comment
Share on other sites

Link to post
Share on other sites

  • 1 month later...

Bump. Going to do some further work to the guide soon.

Link to comment
Share on other sites

Link to post
Share on other sites

  • 2 weeks later...

Bump. Going to do some further work to the guide soon.

Any idea how to fix document previews not opening?  I have libreoffice installed on the server.  Pictures work

Linux "nerd".  If I helped you please like my post and maybe add me as a friend :)  ^_^!

Link to comment
Share on other sites

Link to post
Share on other sites

Bump. Going to do some further work to the guide soon.

Jk.  It was labeled as a bug 4 days ago.  So anyone interested in video streaming, stick with OC6

Linux "nerd".  If I helped you please like my post and maybe add me as a friend :)  ^_^!

Link to comment
Share on other sites

Link to post
Share on other sites

Any idea how to fix document previews not opening?  I have libreoffice installed on the server.  Pictures work

Pictures don't use libreoffice to preview. Are you sure you have the correct link to the libreoffice in the "config.php" file? 

15" MBP TB

AMD 5800X | Gigabyte Aorus Master | EVGA 2060 KO Ultra | Define 7 || Blade Server: Intel 3570k | GD65 | Corsair C70 | 13TB

Link to comment
Share on other sites

Link to post
Share on other sites

Pictures don't use libreoffice to preview. Are you sure you have the correct link to the libreoffice in the "config.php" file?

Libre office is a dependency for the server

Linux "nerd".  If I helped you please like my post and maybe add me as a friend :)  ^_^!

Link to comment
Share on other sites

Link to post
Share on other sites

Is this a ponzi scheme :mellow:

The most common result of insufficient wattage is a paperweight that looks like a PC

Link to comment
Share on other sites

Link to post
Share on other sites

Libre office is a dependency for the server

Okay, but are you sure that the link to the binaries in the configuration file are correct?

15" MBP TB

AMD 5800X | Gigabyte Aorus Master | EVGA 2060 KO Ultra | Define 7 || Blade Server: Intel 3570k | GD65 | Corsair C70 | 13TB

Link to comment
Share on other sites

Link to post
Share on other sites

Okay, but are you sure that the link to the binaries in the configuration file are correct?

ill have to check later

Linux "nerd".  If I helped you please like my post and maybe add me as a friend :)  ^_^!

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×