Saturday, January 24, 2009

Creating a Home Server

Building a Home Server

I spent some time playing with various Home Servers, first I tried Windows Home Server (WHS) and then later went on to Linux.

WHS is not bad but really does not do that much, basically it is a glorified NAS, Net Work Attached Storage, it backs up your client PCs quite well and snap shots so you can pick restore points, plus it gives your remote file access. Well, I have a NAS box at home that is the size of a shoe box, is quiet and lower power. Plus I have backup software on the all clients that do backup. I really don’t care about backing up OS files, rather just data. Why do I want to restore OS files to a state that lead to a crash? Simply gives me a reason to wipe a box clean with a fresh install of the OS then restore the data, really not a big deal and keeps my PCs healthy longer. I have yet to have HW related crash in 20+ years of owning PCs, they have all been OS corruption related. Plus I want to host my own domain, not a WHS named domain, and in the future I want to host my own email server from home. WHS is not really a good option for the use cases I want. So, I played with WHS for a week or so, it does a fine job at what is intended, home backup and remote file sharing. But like I said, most NAS boxes do that pretty well already. I did like the Jungle Disk add on for backing up to Amazon S3, pretty good idea and use model. Jungle Disk allows your WHS to back up to a Amazon S3 account. Jungle Disk works well and integration with S3 is quite good. That said, I had Vonage VOIP phone and when backup was running it knock out any outgoing voice. I ended up switching to Time Warner Digital phone since it puts voice and data on separate channels, and upgraded to Turbo Cable do bump my upload speed from 384kbs to 3mbs to allow backups to S3 to complete. At 384kbs upload it was going to take 30+ days to back up 60GB into the Amazon Cloud.

So, after WHS for a week or so I went on to Ubuntu Server. In very short order I was able to create a Linux Home sever that can act as a File Server for backup, get remote file access, and Host a Server in my house. The steps I used are below, hopefully I did not miss documenting anything to big.

My Steps:

Download Server version from http://www.ubuntu.com/getubuntu/download, make sure and select Server not Desktop.

Ubuntu Server 8.10 -> default install (make sure and install all the LAMP components; Linux, apache, mySQL, PHP, and file server components (Samba))

Install webmin

Download latest webmin using the following command

wget http://prdownloads.sourceforge.net/webadmin/webmin_1.441_all.deb

Now we have webmin_1.441_all.deb package you need to install using the following command

sudo dpkg -i webmin_1.441_all.deb

If your server complains that there is some library things do not find. Just run the following command

sudo apt- get install -f

Change to Static IP

Note: you may need to configure your home router for where it start DHCP addresses so you don’t get a conflict. You need to do this since you need to configure your router to forward the addresses below to the staticIP address you want to use, in my case my static IP address is 192.168.1.9. So I need to forward certain ports to this static IP address

Router Port Forwarding:

Port 443-443 TCP -> Static IP Address (192.168.1.9)

Port 4215-4215 TCP -> Static IP Address (192.168.1.9)

Port 80-80 TCP -> Static IP Address (192.168.1.9)

Now make the Static IP changes on Ubuntu (using vi editor, search Google for VI commands if you don’t know VI).

sudo vi /etc/network/interfaces

If you are using DHCP for your primary network card which is usually eth0, you will see the following lines:

auto eth0

iface eth0

inet dhcp

As you can see, it’s using DHCP right now. We are going to change dhcp to static, and then there are a number of options that should be added and here is an example, and you can change these settings according to your network settings.

auto eth0
iface eth0

inet static
address 192.168.1.9
netmask 255.255.255.0
broadcast 192.168.1.255
gateway 192.168.1.1

Restart the networking service using the following command

sudo /etc/init.d/networking restart

Remote Login via terminal:

Vista does not have a terminal so we need to download one, on your XP or Vista box download Putty from:

http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

Run Putty and use the static IP address above to log into the Server

Now that we have SSH Terminal access you can quit Putty

Web Access to Manage Server

Now you need to open your web browser on XP/Visita and enter the following web address

https://192.168.1.9:10000/ -> StaticIP address we used above

Now you should see a Login to Webmin screen.

Ubuntu in particular don’t allow logins by the root user by default. However, the user created at system installation time can use sudo to switch to root. Webmin will allow any user who has this sudo capability to login with full root privileges. After login if you want to configure Apache, mySQL Server,….. you need to click on Servers from the lefthand menu of Webmin.

Create a directory for your web site and that is shared so you can your HTML:

Using Putty, login and go to your /home/ and create a directory using

mkdir public_html

Now, using Webmin from host PC, https://192.168.1.9:10000/

Click on Servers->Samba Windows File Sharing

Then File Share Defaults and select Directory to share: /home/Robert,

Also click on available=yes and browsable=yes

Then click on file permission defaults and click on can delete readonly files = yes.

Then save/return

Then click on security defaults and select writable = yes, host to allow = all, host to deny = none

Then click save/return

Then to go back to windows file sharing and select create file share

Select /home/Robert and click on the home directories share, available=yes, brwsable = yes.

Then save/return and select restart Samba Servers.

You should be able to access the share via windows PC by Start->Run-> \\192.168.1.9 (static IP address you used)

I may have forgotten to mention all the steps here but it is pretty intuitive.

Apache Setup

Add ServerName to resolve name dependency

Add the following line somewhere:

ServerName localhost -- not the name of the server, actually ServerName

sudo vi /etc/apache2/apache2.conf

/* add this line - “ServerName localhost” somewhere in the file */

and restart Apache.

sudo /etc/init.d/apache2 restart

Create a new Apache site

To create a new site, first create a directory where you want to keep files associated with this site. I like to keep sites in my home directory so (using my user name of robert) I create a /home/robert/public_html directory. So using Putty, open up a session

mkdir /home/robert/public_html

The configuration files for all sites available to Apache are stored in the /etc/apache2/sites-available/ directory.

Create a configuration file for your new site (here called robert) by copying the configuration file for the default site.

sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/robert

Open the new configuration file.

sudo vi /etc/apache2/sites-available/Robert

You will notice that there is a lot of stuff between tags.

You have to edit some of this. Change the DocumentRoot path to point to the newly created site directory.

DocumentRoot /home/robert/public_html

In a similar fashion, change one of the Directory directives (it looks something like this)

to be consistent with your site path.

After making these changes, disable the default site using the Apache disable site script.

sudo a2dissite default

Next, use the Apache enable site script to activate the new site.

sudo a2ensite robert

Finally, restart Apache.

sudo /etc/init.d/apache2 restart

Create a simple index.html file and save it in /home/robert/public_html/ to test your new site. Something simple like


Ubuntu Apache2 Web Server is Here

Browse your new site to test the configuration by opening your browser and typing in the Static IP address in your web browser.

Dynamics DNS Setup:

Home broadband (cable, dsl) IP assignment from your internet provider is dynamic, and thus we need a solution to this problem to host our own domain at home. Dynamic DNS services fix that problem by hosting your domain and providing re-direction services to your local web server. This is accomplished by having an agent on your home server that sends out a homing beacon to the service so they know where to re-direct the web hit. No-ip is one of many services out there, you can take out your domain with them, they provide you an agent and the agent understands the your account at no-ip and re-directs web hits to your local machine.

Goto www.no-ip.com and register your desired domain for DNS+

Now you will need to install the client. Open up your terminal and run

sudo apt-get install no-ip

and follow the prompts based on the account you setup.

Wait several hours up to 24hrs for DNS propagation and then try to access the web site you created using the domain name you registered.

Creating Web Pages

Now you can use FrontPage, Impression, etc…. and simply save to the shared location you created at \\StaticIP\...\public_html on your home network.

Misc Need to know Linux Commands:

sudo shutdown –h now -> Shut down

sudo apt-get update -> Update is used to resynchronize the package index files from their sources via Internet.

sudo apt-get upgrade -> Upgrade is used to install the newest versions of all packages currently installed on the system

sudo reboot

Making your home server host email:

wip

Utilities

Album – album builds web pages by traversing a directory tree and creating thumbnails and linking index pages to allow viewing on the web. Simply create a directory in your public_html and copy all the picture folders you want, then using putty go into that directory and run album with the defaults, lots of options but default is not bad for a start.

http://manpages.ubuntu.com/manpages/intrepid/man1/album.html#toptoc0

--rwh


Sunday, January 18, 2009

1/18/2009 First Entry

First BLOG entry, nothing to add just yet.