dinsdag 18 november 2014

[HOWTO] Set up your owncloud home server with Ubuntu server 14.04 LTS (in Belgium with Telenet ISP)


So this is an issue I have been struggling with for a very long time, so I thought sharing it with the world would be my ultimate reward :) I always wanted to have my very own home server that pretty much works like Dropbox, but has an unlimited amount of space AND is accessible from outside my home network. And boy does it work like a charm :)

This guide will attempt to learn you the following things:

  • Install Ubuntu Server Edition 14.04 LTS on an old PC
  • Install a GUI (desktop environment) on the Ubuntu Server for easy access
  • Install an Owncloud Cloud Sharing Server on your Ubuntu Server
  • Make your Owncloud accessible from outside your home network (with instructions for people who live in Belgium and have Telenet as their ISP)

Let's get to it! 

CHAPTER 1: install Ubuntu Server 14.04 LTS on your PC


First things first: let's start by installing a fresh Ubuntu Server on your old PC.
  1. Go to ubuntu.com, and download the ISO file of the server edition to your liking. I used 14.04 LTS for the 5 year long support and updates. Just go to this link: http://www.ubuntu.com/download/server
  2. Burn the ISO on a disk or USB stick (you might wanna check the BIOS of the PC that will carry the server if you can boot from USB before burning the ISO to a stick). I won't go into detail on this as there are plenty of guides online on how to burn an ISO image :)
  3. Boot your old PC from the disk or USB stick you just burned. The installation program of the Ubuntu Server will start up. Don't forget to change the language and keyboard layout before hitting the install button on the first boot screen :) Make sure your PC is connected to the internet!
  4. Go through all steps of installing Ubuntu Server on your PC. There's nothing really hard about that as for the owncloud server, you don't really have to change any of the default settings already filled in at installation. The only thing you might wanna get some attention to is the partitioning of your hard drives. I always prefer to select 'manual configuration' as it's not hard to fill in and you have total control of how you want your hard drives to look like. Step 5 will go into detail for partitioning.
  5. PARTITIONING:
    My set up is as follows: I have one HDD where I wanted to install the operating system on, and one HDD of 3TB for all my files that I wanna access through Owncloud. I had to create the following partitions: 
    1. Create a SWAP partition instead of an EXT4 partition of at least 2GB
    2. Create an EXT4 partition with mount point '/' for your HDD that will carry the operating system
    3. Create an EXT4 partition with mount point '/hdd2' for your HDD that will carry the files for Owncloud. You can change the hdd2 in whatever you like.
  6. When asked which packages you want installed on your Ubuntu Server (eg. LAMP, Windows Samba, FTP...), don't check any of that packages. You won't be needing them anyway.
  7. That's it, you should be having an Ubuntu Server installation up and running on your PC. When you reboot, you should be able to login and see a command line. Next step is installing a desktop environment on your server for easier access :)

CHAPTER 2: install a desktop environment on Ubuntu Server 14.04 LTS


Now many people will say that you shouldn't do this to keep your server more secure, but as this is a simple home server, I prefer to have a mouse pointer and desktop interface available for easier access. Didn't regret installing this :) We will install a stripped down version of Lubuntu on this server with the least possible amount of packages necessairy to get it up and running. 

  1. Login to your ubuntu server and wait for the command line
  2. When you see the command line. Fill in the following commands:

    sudo apt-get install lxde-common --no-install-recommends
    sudo apt-get install lubuntu-core --no-install-recommends

    This will install the essential Lubuntu desktop environment for you.
  3. To get Lubuntu up and running on your next reboot, you'll have to create a session file. Fill in the following command to create that file:

    sudo touch ~/.xsession

    Edit the file using the following command:

    sudo nano ~/.xsession

    Fill in the following (and only) line in that file:

    lxsession -s Lubuntu -e LXDE

    Save it, and reboot using 'sudo reboot'. You should be getting the Lubuntu login screen on your next startup :)
  4. When you logged in into your lubuntu environment, you can install some additional packages to make your workflow easier (this is optional): 
    1. install a webbrowser to access the owncloud web interface (midori is the most lightweight webbrowser around to do the job):

      sudo apt-get install midori
    2. install GDebi package installer to easily install Teamviewer in the next step (if you like)

      sudo apt-get install gdebi
    3. install Teamviewer to easily access your server from another computer. Go to teamviewer.com to download the latest version. Open up GDebi and open the downloaded package with it to install it.
    4. install a text editor to easily modify configuration files without having to use nano in the terminal:

      sudo apt-get install leafpad
That's it, you should have Lubuntu up and running on your server :)

CHAPTER 3: Install Owncloud on your Ubuntu Server 

  1. You can easily install Owncloud through the OpenSuse repositories. To add them, just go to this page for further instructions (don't forget to add the key for the repo as well, instructions are also on that page). After adding the repo's, just fire up a terminal and install owncloud using:

    sudo apt-get install owncloud
  2. (optional) After installing Owncloud, you should give the owncloud user permitions to your second HDD where you wanna store your files (if you have one, if you have just one HDD, skip this step):
    1. First, make a directory in your second HDD where you want Owncloud to store your files:

      sudo mkdir /path/to/your/second/HDD/owncloud

      So for me that was: sudo mkdir /hdd2/owncloud
    2. Now give permitions to the Owncloud user to use that directory:

      sudo chown -R www-data:www-data /path/to/your/second/HDD/owncloud

      So for me that was: sudo chown -R www-data:www-data /hdd2/owncloud
  3. Now you can fire up a webbrowser and see your Owncloud server in action :) Type in http://localhost/owncloud and hit enter. You should see this first run screen where you can choose your admin user and fill in the path to your owncloud folder (hit the 'advanced' button to see everything):

  4. Click finish setup. When you get an error message saying that your owncloud installation can't access its database, you should have a look at step 2 where I explained how to give owncloud permition to the owncloud folder you've chosen. Be sure it has full writing permitions!
  5. To access your owncloud installation from another computer in your network, just type in the following in a webbrowser:

    http://IPAdressOfYourServer/owncloud

    To know the ip-address, simply open a terminal on your server and type 'ifconfig'. This should return your ip-address something like 192.168.x.x.
  6. Hooray, you got owncloud up and running! Now go to owncloud.org to download the desktop clients so you can start syncing :) When they ask for your owncloud-server, simply fill in the address of step 5. If you want to access your Owncloud installation from outside your home network, you're not quite done yet :) 

CHAPTER 4: access your Owncloud installation from another network (with instructions for ISP Telenet in Belgium)

Here come's the tricky part. Many ISP's (such as my own Telenet) won't allow you to access any server installed in your home through your IP-address and the default port 80 (through which all websites are installed by default), so you will have to change the port on your webserver installation. Luckily, this is not so hard as Owncloud is installed on an Apache webserver which is very easy to configure. 

We will change the default port to access our owncloud installation from 80 to 8080. 
  1. fire up a terminal and type:
    sudo leafpad /etc/apache2/ports.conf
  2. in that file, change 'listen 80' to 'listen 8080'
  3. save the file, exit leafpad, and restart your apache web server using:

    sudo service apache2 restart
  4. To test whether this worked, open up a webbrowser and try accessing your owncloud installation with its new ports:

    http://localhost:8080/owncloud

    If the owncloud login screen shows up, that means it worked!
Now we will go into our home router settings to point all incoming traffic on port 8080 to our server. I will include screenshots of my own router settings at telenet, they may look different in your case. The basic idea is to point incoming port 8080 to the internal ip address of your server (the one we used in chapter 3, step 5 which looks like 192.168.x.x). This is how I filled in my settings at 'mijn telenet', the router admin suite at Telenet. For people also trying to fix this on Telenet: go to 'mijn telenet' > internet > draadloze instellingen > geavanceerd > ipv4 firewall & port forwarding to get this screen:



Save your settings, and test whether you can access your owncloud server from your external IP-address (you can find it at whatismyipaddress.com): 

http://YourExternalIPAddress:8080/owncloud

Did it work? Great! Enjoy your owncloud server! Most ISP's though have a dynamic IP assigned to you, which means that your IP address may change over time. To not having to remember the IP address all the time, you can use a dynamic DNS website to remember it for you. That way, your IP-address will have a simple domain name like MyWebsite.ddns.net, and it will always point to your IP-address, even if it has changed. 

A website which offers dynamic DNS is No-IP. Head over to their website, create an account, and fill in your ip-address details as shown in the screenshot below: 

Now you can access your owncloud server through the domainname you just gave to your IP address :) The only thing left to do is install the No-Ip update client on your server so the domain name always points to the right IP-address. Instructions can be found on this page. You will need the build-essentials package to install this client. You can install it by running: 

sudo apt-get install build-essentials



Wow, I just wrote 2 hours on this howto :p Hope someone will find it useful! As usual, if you have any comments or questions, put them in the comments! I will try to answer them as much as possible (though I'm also pretty new to this stuff :) )

Have a nice day!



PS: Credits go to all the nice people I gathered information from on the internet, thank you so much!
http://ubuntuforums.org/showthread.php?t=2222849&page=2
http://matveen.blogspot.be/2013/04/set-up-owncloud-server-at-home.html
http://doc.owncloud.org/server/7.0/admin_manual/installation/installation_linux.html

Geen opmerkingen:

Een reactie posten