Your own ownCloud
ownCloud In this day and age where many people are more and more dependant on information, cloud technology offers a way to unlock your information to you, wherever you are, on most any device. However, there's no telling what the cloud companies that you entrust with your information will do with that info - let alone nosy intelligence agencies from various countries around the world. My privacy matters to me!
ownCloud is a free and open source alternatives for many cloud offerings such as Google Drive and DropBox, as it gives you the ability to share and sync files from your own server, but it does much more - added bonus, I say...
_
_
Introduction
ownCloud broadly comes in two flavours: the open source, free "community edition" and the open source, paid "enterprise edition". We're going to install the community edition here. The goal will be to have a way to share files between groups of people, most of which will have an account on our server.
Installing ownCloud
In the following we're going to install ownCloud manually, that is to say we're not going to use any Linux package manager such as Debian's apt or Red Hat/CentOS's yum, but we're going to manually put the necessary files on the server. This has the advantage of being able to use the very latest & greatest version of ownCloud, but the disadvantage requiring us to do the heavy lifting, install-wise as well as update-wise. However, as we'll see below, a manual installation takes relatively little effort.
Preparing your server
First off we have to ensure that our server complies with ownCloud's requirements, as shown in the administrator manual. This means we'll require a working LAMP server with a sufficient recent version of PHP, MySQL and Apache. If we want to secure our ownCloud communications using SSL, we also need to have a good SSL certificate (preferably not a self-signed one as many applications choke on that signature) and have set up our Apache server to correctly use it. Furthermore, ownCloud needs the Apache module mod-rewrite; usually one can enable it with a command such as a2enmod rewrite.
Getting ownCloud files on your server
Now we'll choose a directory in which the ownCloud files can live; as it's a manual package, the Linux Standards Base (LSB) suggests it goes into /opt. We thus create the directory /opt/owncloud. Next up we download the ownCloud tar.bz2 file from the ownCloud download page to a temporary directory and extract it; this could look like
cd /tmp wget http://download.owncloud.org/community/owncloud-6.0.1.tar.bz2 tar -xjf owncloud-6.0.1.tar.bz2
Note that the extraction causes the tree of ownCloud files to appear in a directory called owncloud. Strictly speaking you could extract the file directly in /opt without first creating an owncloud directory by hand. However I like to keep an eye on processes like this. We can now move all the files from the tar into the prepared directory with a command such as
cp -pR /tmp/owncloud/* /opt/owncloud
Here please note that all files in the tar file are owned by a user with UID and GID 65534, corresponding with nobody:nogroup. If your server or webserver setup require a different user/group, you should use chown to set this.
Publishing ownCloud in Apache2
As we would like all files pertaining to the configuration of our server to live under /etc, we create a directory /etc/owncloud. Now, in this directory we'll create a file named apache.conf containing
Alias /cloud /opt/owncloud <Directory /opt/owncloud> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory>
Publishing the ownCloud instance is now as easy as including this file in the relevant Apache (SSL) site configuration file. Under Debian, this means selecting the right file under /etc/apache2/sites-available/ and insert the line
Include /etc/owncloud/apache.conf
If you now reload Apache with a command such as service apache2 reload, you'll be able to surf to the URL of the pertaining site (e.g. https://www.saruman.biz/owncloud) and verify that the unconfigured owncloud instance is now accessible.
Configuring ownCloud
Initial setup
We'll need a data directory for ownCloud. My recommendation is something like /data/owncloud, and since the web server is required to manipulate files in this directory, we'll make it owned by Debian's webserver user/group www-data:www-data (under other distributions, make sure to use the corresponding user/group). For this directory to be used by ownCloud, we'll symlink to it from /opt/owncloud with command:
ln -s /data/owncloud /opt/owncloud/data
We'll also need a database for ownCloud. To create one, we can start the MySQL client (mysql -u root -p and then the password) and create a database plus database user using
mysql> create database owncloud; mysql> create user 'ownclouduser'@'localhost' identified by '<password1>'; mysql> grant all on owncloud.* to 'ownclouduser'@'localhost';
Now we can surf to the ownCloud instance page, and we'll find the startscreen asking for setup details. Provided the following details:
- Admin account: owncloudadmin/<password2>
- Data folder: /opt/owncloud/data
- Database user: ownclouduser/<password1>
- Database name: owncloud
- Database host: localhost
Once we've finished the installation wizard, we'll be able to log in to ownCloud using the admin account (here owncloudadmin) and the corresponding password.
If logging in works, then the following action will complete the configuration according to the LSB. We'll move the file /opt/owncloud/config/config.php that the installation wizard has created to our directory /etc/owncloud (if you like, you can also move the example configuration file config.sample.php for future reference). Then we symlink to it using
ln -s /etc/owncloud/config.php /opt/owncloud/config/config.php