I decided to write a tutorial today for another Ubuntu 14.04 Server based HTPC and media server setup guide. I’ve read a forum thread where the original poster is asking if there is some way to setup an HTPC File Server Combo on his machine.
Related Topic: How to Build Your Own Cloud Server Using Nextcloud
Some of the respondents answered by suggesting to setup a Samba server or NFS connection, but the post author isn’t skillful enough to setup the thing on his own. So I decided to wrtie this guide on how you would exactly do this, the easy way, using a FREE-AND-OPEN-SOURCE-SOFTWARE (FOSS) called Owncloud. I’ll share this guide later on the forum site. So with Owncloud, XBMC (KODI in next release) plus Ubuntu Server 14.04 LTS, we could put up a configuration that will serve as an HTPC, DLNA server, streaming media server, file server, that has a file sync feature like the one offered by Dropbox or Google Drive.
But what the heck is Owncloud anyway?
Stylized as ownCloud, it is generally free and OpenSource software that functions like a Dropbox (for the file Sync part). Almost all of us know that Dropbox is a free cloud-based file hosting service with file synchronization feature. It’s a free (up to 2GB) personal cloud storage service. It’s very similar with Owncloud, the difference is, you have to provide your own hardware/infrastructure where you could install Owncloud and configure it as your privately-owned cloud server or cloud storage, and file server solution. You could install and use Owncloud within your own internal network, as well as, to a cloud VPS (Virtual Private Server) like the ones offered by Amazon AWS and DigitalOcean.
Owncloud, like any other software, you need to install and configure it afterwards to match your intended mode of operation. Like Dropbox, Owncloud has a client connection software that automatically syncs your local file/folder to your private cloud folder. It also has a WebDAV feature that you could connect to, from various clients (Smartphones and Desktops) by just accessing your webdav server address. Connecting to your account using webdav is simple and easy, just take note of your user account and your webdav address.
ownCloud WebDAV address uses the following format:
Purpose of This Guide
The main purpose of this guide, is to setup an Linux-based media server, a file server, a DLNA server, a streaming media server, and at the same time an HTPC, all under one machine. This build is going to be a power-saving machine that you could power-on 24 hours a day, seven days a week. You also call this as a multi-in-one htpc media server.
For this guide, you need a machine powerful enough to serve your desired services and mode of operation. I’m not going to run through the details, but to give you an idea, you at least a 4GB RAM, Quad-core CPU, ATI Radeon HD5400 or newer/Intel GMA X4500HD or newer, large hard-drive (or RAIDED drives) and most of all, a high-quality Gigabit Ethernet Card. You also need to have XBMC (or Kodi) and Plex already installed on your system. If you have not done this yet, then you need to follow my
For the Owncloud Installation Part
Since this tutorial involves Owncloud manual installation on a Linux-based machine (Ubuntu Server 14.04 LTS), it requires command-line typing using Linux terminal or Windows
putty.exe. Don’t be discourage by this because I will make it very easy for you. You may copy-and-paste most of the commands and you just need to substitute the values applicable to your installation.
For this guide, we need to do the following:
- Connect to the target machine remotely via SSH
- Install Apache 2 Web Server
- Install MySQL Server
- Install Owncloud dependency packages
- Create a new VirtualHost
- Download Owncloud manual installation package
- Enable VirtualHost & Install Owncloud (keep in mind that Ubuntu 14.04 LTS is the Host-OS)
- Configure Owncloud
- Test connect a client device/machine
You must be comfortable with command-line
Note: You need putty.exe if you’re on Windows.
The details and values used in this guide are:
- Hostname =>
- FQDN or Fully Qualified Domain Name =>
- User Account used from the HTPC =>
- VirtualHost or Domain Name for the Owncloud instance =>
- Database name used for Owncloud =>
- Database user-name used for Owncloud =>
- Database password used for Owncloud =>
- MySQL Root user-password =>
- Admin user-name & user-password for Owncloud =>
admin/adminThese are the values I’ve used in this guide. You should use your own values.
Step 1: Connect to your HTPC remotely via SSH.
You could actually install Owncloud directly from your XBMC or HTPC machine, but the advantage of using SSH is that, you could easily copy and paste codes in your command-line and you don’t have to manually type in the long syntaxes for the installation. To connect to your target machine using SSH, open up putty.exe or a terminal in Linux (ctrl + t), then type in
ssh firstname.lastname@example.org. chubbable is my user-name on my HTPC machine with a static IP address of
192.168.1.252If it’s your first time to connect, you’ll be greeted with a message
The authenticity of the blah... blah..., make sure that you’re connecting to your target machine, type
yesand press enter to continue. You should be now logged-in remotely to your HTPC machine.
Step 2: Download the latest version of ownCloud.
To do this, head over to
https://owncloud.org/install/and click the button labeled
Archive Files For Server Owners. A new mini-window should pop-up. Reference Image: [jig ids=”1754″] From the pop-up window, you should see a list of available choices. In this case, you need to download the Unix package for ownCloud in an archived file. From the number one entry, right click
Unixlink and choose
Copy link addressfrom the context menu. Reference Image: [jig ids=”1755″ In my case, I’ve copied this link: `https://download.owncloud.org/community/owncloud-7.0.1.tar.bz2` > Note: That is the latest version of ownCloud as of the time of writing this post. Now go back to your terminal or putty.exe window and paste it in the command-line. Prepend it with `wget` plus `space`, so it should look like this; `
\` wget https://download.owncloud.org/community/owncloud-7.0.1.tar.bz2 ``
\Press `Enter` key to start downloading the file. Reference Image: [jig ids=”1757″ After downloading the file, extract it by typing the following or you may just copy and paste it to your command-line.`
\`tar xvfj owncloud-7.0.1.tar.bz2 ``
\A new folder labeled `owncloud` should be listed when you check your home folder by typing `ls + enter key`. Reference Image: [jig ids=”1758″]
Step 3: Install Apache2 web server and other dependency packages.
Since ownCloud is a web-based application, it needs to have a web server to run on. Just like any other web-script (ie. WordPress), it requires a web host to be installed on. So for this step, we need to install Owncloud’s dependency packages and at the same time install Apache 2 web server, MySQL Database server and PHP (plus important modules). You could just copy and paste the codes used in this step. You just have to substitute the values that are most applicable to your case. To continue with this step, copy the following code and paste it in your command-line, then press ENTER key. Input your user-password when asked.
sudo apt-get install lamp-server^ php5-gd php5-json php5-curl php5-intl php5-mcrypt php5-imagick -y
It’ll take around 10 minutes for this to finish. It depends on your Internet and system-drive’s speed. During the installation process, a new screen should pop up similar to the image shown below.
Reference Image: [jig ids=”1760″]
Nominate a password for the MySQL Database
rootuser account. So input your password, then hit ENTER key. You’ll be asked to enter it twice for confirmation and double-checking. Installation should continue.
After the install process, you should be back to your command-line.
Now, you’re ready for the next step.
Step 4: Create the document root folder for
cloud.loc. To do this, copy and paste the following code and press ENTER key:
sudo mkdir /var/www/cloud.loc
sslfolder to hold your SSL Certificate files:
sudo mkdir /var/www/cloud.loc/ssl
logsfolder to store your log files:
sudo mkdir /var/www/cloud.loc/logs
Step 5: Copy the
owncloudfolder or better yet move it to your virtualhost’s document root by typing the following command.
sudo mv owncloud /var/www/cloud.loc/
To confirm that you actually move the whole folder, type
cd && ls /var/www/cloud.loc
You should see the folders
Reference Image: [jig ids=”1761″]
Did you see them? Cool! Now continue with the next step.
Step 6: After the above step, set permission to your
ownClouddocument root by copy-pasting the following command:
sudo chown -R www-data:www-data /var/www/cloud.loc/owncloud
sudo chmod -R 755 /var/www/cloud.loc/owncloud
Open and edit the
hostsfile and insert
sudo nano /etc/hosts
Reference Images: [jig ids=”1763,1764″]
Note: You may change cloud.loc to anything you want.
Add your domain name to your client machine’s
hostsfile. If you’re on Linux, you could do this by typing this in your commandline:
sudo nano /etc/hostsThen write a new line of text and add the IP address of your XBMC or HTPC machine and then your domain name.
This requirement should be done on your client machine,
not your XBMC or HTPC machine. In my case, I did it like so:
Save the file by pressing
ctrl + o->
ctrl + x.
To do this in windows XP/7/8, navigate to
system-folder\system32\drivers\etc\and edit the file
hosts. It’s a hidden file, so you need first to enable
Show hidden filesoption in Windows EXplorer.
Step 7: Create a Self-signed SSL Certificate For your ownCloud instance.
You need a self-signed certificate to be used with your SSL virtualhost in Apache. Creating this certificate is simple, you may just copy and paste the commands below. This step should enable
httpsconnection in ownCloud.
Create the SSL Certificate. Copy-paste the command to create the certificate:
sudo openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout /var/www/cloud.loc/ssl/owncloud-ssl.key -out /var/www/cloud.loc/ssl/owncloud-ssl.crt
A new screen should open and will ask for various details like Country and State. This is how I entered my data:
- Country Name (2 letter code) [AU]:
- State or Province Name (full name) [Some-State]:
- Locality Name (eg, city):
New York City
- Organization Name (eg, company) [Internet Widgits Pty Ltd]:
- Organizational Unit Name (eg, section):
- Common Name (e.g. server FQDN or YOUR name):
- Email Address:
You can now check for the files from the
cd && ls -l /var/www/cloud.loc/ssl
Reference Image: [jig ids=”1765″]
You should see
Now you might wanna ask your self, how to use SSL in ownCloud?
The answer can be found in the next step below.
- Country Name (2 letter code) [AU]:
Step 8: Create an SSL VirtualHost.
This is the part where you will use the SSL files you’ve generated from the previous step above. After successfully creating the certificate files, you now need to create the SSL virtual host for your domain. To do this, copy the file
/etc/apache2/sites-available/default-ssl.confand paste it to a new file called
To do that, type the following and press
sudo cp /etc/apache2/sites-available/default-ssl.conf /etc/apache2/sites-available/ssl-cloud.loc.conf
Add the path to your SSL certificate files, open the file by typing:
sudo nano /etc/apache2/sites-available/ssl-cloud.loc.conf
Edit the file to look something like this:
<ifmodule mod_ssl.c> <virtualhost _default_:443> ServerAdmin email@example.com ServerName cloud.loc ServerAlias www.cloud.loc DocumentRoot /var/www/cloud.loc/owncloud ErrorLog /var/www/cloud.loc/error.log CustomLog /var/www/cloud.loc/access.log combined SSLEngine on SSLCertificateFile /var/www/cloud.loc/ssl/owncloud-ssl.crt SSLCertificateKeyFile /var/www/cloud.loc/ssl/owncloud-ssl.key <filesmatch "\.(cgi|shtml|phtml|php)$"> SSLOptions +StdEnvVars </filesmatch> <directory /usr/lib/cgi-bin> SSLOptions +StdEnvVars </directory> BrowserMatch "MSIE [2-6]" \ nokeepalive ssl-unclean-shutdown \ downgrade-1.0 force-response-1.0 BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown <directory /var/www/cloud.loc/owncloud> Options Indexes FollowSymLinks MultiViews AllowOverride All Require all granted </directory> </virtualhost> </ifmodule>
Save the file, and enable the SSL virtualhost.
To do this:
sudo a2ensite ssl-cloud.loc.conf && sudo service apache2 restart
Reference Image: [jig ids=”1766″]
If there is no error upon Apache restarts, then you’ve successfully enabled your SSL VirtualHost.
Step 9: Create a Virtualhost for your ownCloud instance.
This virtual host will host your domain for your Owncloud instance. In my case, I named my domain like so,
cloud.loc. For this step, you need to create a new virtualhost and set the document root to be used by Owncloud. To do this, create a new
.conffile for your Owncloud virtualhost. It’s better to use a file name that reflects your domain name. In my case my local domain name is
cloud.loc, so I would name my
.conffile like so,
To create the file, type or copy this:
sudo nano /etc/apache2/sites-available/cloud.loc.conf
A new black screens should pop up. Copy and paste the block of codes and the save the file by pressing
ctrl + o->
ctrl + x.
<virtualhost *:80> ServerName cloud.loc ServerAdmin firstname.lastname@example.org DocumentRoot /var/www/cloud.loc/owncloud ErrorLog /var/www/cloud.loc/logs/error.log CustomLog /var/www/cloud.loc/logs/access.log combined <directory /var/www/cloud.loc/owncloud> Options Indexes FollowSymLinks MultiViews AllowOverride All Require all granted </directory> </virtualhost>
Note: Substitue the correct path in your case. Save the file and exit. Then enable your newly created virtualhost by invoking the following command:
sudo a2ensite cloud.loc.conf && sudo service apache2 restart
Reference Images: [jig ids=”1767″]
Step 10: Enable Apache Mods for ownCloud.
sudo a2enmod rewrite ssl headers && sudo service apache2 restart
Reference Image: [jig ids=”1768″]
Step 11: Check your ownCloud domain and see if it’ll connect via HTTPS connection.
Access your ownCloud domain using
https://cloud.locIf you see a splash page saying
This Connection Is Untrustedusing Firefox, then that’s a good indication that you’ve configured SSL in ownCloud correctly.
To continue, click
I Understand the Riskand then
Confirm Security Exception.
You should be then redirected to the Admin Web-GUI.
Reference Images: [jig ids=”1769″]
In Google Chrome, you’ll see a page like this:
Reference Image: [jig ids=”1770″]
You just need to click
Proceed Anywaybutton to continue logging in.
Step 12: Create a new database for ownCloud installation.
First login as root to MySQL server via commandline.
Type-in the below code and hit ENTER key.
mysql -u root -p
You’ll be prompted to enter your MySQL root password (the you entered during Step 3), enter it and press enter key.
Referecne Image: [jig ids=”1771″]
You should now see a new command-line starting with
Create the new database by typing the following command and press ENTER key.
CREATE DATABASE owncloud;
Create new user and grant privileges to the new database.
GRANT ALL ON owncloud.* TO 'owncloud'@'localhost' IDENTIFIED BY 'owncloud';
Then reload user privileges to set the privileges for the user.
Done! Exit the prompt by typing
Switch to your browser and access your domain name. Then proceed to the next step.
Note: owncloud and admin are for illustration purpose only. Use your own values.
Step 13: Install ownCloud by initiating the installation wizard.
cloud.locand fill up the necessary fields on that page.
In my case, I’ve filled up the fields like so:
- admin user-name =>
- admin user-password =>
- database user =>
- database password =>
- database name =>
After filling the necessary fields, click
Finish setupbutton and you should be taken to the ownCloud admin page.
If you reached the page similar to the image shown above, then you’ve successfully installed ownCloud on Ubuntu Server 14.04 LTS.
To configure it as a file server with XBMC/HTPC, follow the post-install guide and configure ownCloud from it’s Web-GUI.
- admin user-name =>
Post Install Configuration
The next task that you need to do is to enforce https connection to your ownCloud server. This settings will always redirect a user to the secure side of your server.
If a user just typed
cloud.loc in the address bar, owncloud will redirect it to
So how to always enable HTTPS in ownCloud?
To enable HTTPS connection to your ownCloud-based file server, you need to login in again using the
https protocol. So if you’re logged in right now, logout first and then login again using
https://cloud.loc. Then navigate to main
admin menu from the top-right corner of the page, then hover your mouse to
Admin and click it, scroll down a little further till you see the
Enforce HTTPS check-box. Tick the box and you’re done.
Reference Image: [jig ids=”1773″]
Using The File Sync Feature
To use this feature, first create a client user account from the administration page. You may assign a group for this account and also provide disk quota. Doing this is very straight forward, thanks to ownCloud’s simple, clean but feature rich web-ui. After creating the account, install the client software which can be downloaded from
this page. You may choose and download the client software for either desktop clients or mobile devices. After downloading the client app, install and run it from your device. Installing it is fairly easy, especially on Windows and Mac.
To connect from Windows machines, run the app and fill up the
Server Address in the following format:
Then click next, a new window should pop-up warning you about SSL connection, double check the certificate and tick
Trust this certificate and finally click ok.
You should be then taken to the login windows. Now fill up the user-name and password field and click next.
The next dialog will let you choose your local folder, you may choose another folder or just accept the default folder path, which is
Connect then FINISH.
ownCloud should be running now already and minimized in your system tray like Dropbox does. Now you’re ready to make the sync.
Connecting from Mac or Linux is very similar, so you may just use this Windows guide as a reference.
Reference Images For Windows Client: [jig ids=”1786,1787,1794,1795″]
Connecting To WebDAV
After a successful installation, you got really excited and you wanted to test the server straight away. So you might ask, how to connect to ownCloud?
Connecting to ownCloud is fairly easy, you just need to get your WebDAV server address. In this case, my server address is
https://cloud.loc/remote.php/webdav/. You could use an IP address instead of a domain name.
How to connect using Linux Mint? Connecting to ownCloud from a Linux Mint desktop is fairly easy, just open up your file explorer (ie. nemo) then go to main menu then:
Click File -> Connect To Server
A new pop-up mini-window should open. Fill up:
Typedrop-down menu and select
Secure WebDAV (HTTPS)
- Fill up
- User Name and Password
Note: Do not include the https or http when filling up the Server field, else it will throw an error saying, HTTP Error: Cannot resolve hostname (https). Finally, click connect to make the connection. Reference Image: [jig ids=”1774″] Connecting from Mac is fairly easy too and very similar. Just open up your explorer then go to main menu ->
Connect to Server. How to connect from XBMC? To connect to ownCloud using XBMC, go to
Add Videos. Then click
Add Network Location.
A new mini-window should pop-up. The fill up the fields like so:
- From the
Protocoloption menu, select
WebDAV server (HTTPS)
- Fill up
cloud.locor just an IP address
- Fill up
- Fill up user-name and user-password
- Finally, click OK to make the connection Then continue adding media files the usual way. Thats it! Reference Image:
With the power of Open Source projects, you can accomplish many things on top of ordinary. As you have witnessed in this guide, we’ve installed a web-server plus ownCloud in addition to your existing XBMC-based HTPC and Plex media server. This is made possible by our Host-OS, which is Ubuntu 14.04 LTS server. In this guide, you’ve learned how to install owncloud in Ubuntu 14.04, and also, you’ve build yourself an HTPC-File-Server combo from scratch using free downloadable software. So if you’ve completed this guide successfully, pat yourself on the back. For those who need further help or anyone who wants to improve this post, feel free to make a comment below. Thank you all for taking your time in reading this setup guide.