The Home Server

a Tutorial by NorthBear

           

Introduction

A lot of people have been brought up with the idea that a server computer is a big, "scary" thing. This comes from enterprise servers that need to support hundreds of connections per second and be available continuously, otherwise the business loses money.

However, the home server doesn't need to be anything more than an ordinary desktop style machine. Let's face it, a home server isn't going to need to support anything more than a handful of connects at one time and if it's not online right now, that just means you can't listen to your music collection for a while.

So relax! A lot of older, cheap harware will work great for a home server and the software can be a breeze with any of the "server style" Linux distros that are readily available. For this tutorial, I'll be using Centos 5.1.

Why build a home server? Today's home server can do so much more than just dishing out web pages to the local client's web browser. Here's a short list:


  •     Web server
  •     Email server
  •     Video/Audio media server
  •     DNS server
  •     Caching proxy server
  •     File sharing server
  •     Rsync backup server
  •     Gaming server
  •     Local software repository server

So, a local server can really speed-up access to a lot of web stuff with a caching proxy or a local repository. Streaming audio and video is a lot of fun and being able to filter Email for spam and viruses is a great feature. And what fun would life be without a game server?  




Part 1: Preparing the Server





Software Installation

The bittorrent for the Centos 5.1 DVD is very fast, I got my copy in less than an hour. Centos is based on RedHat Enterprise Linux, the difference being that Centos has replaced RedHat's copyrighted artwork, etc. The installation process is very much the same as RedHat EL or Fedora. There are a couple areas of interest, however:

  •     Network IP Address
  •     Server and Server GUI

The network IP address for the server should be set to a fixed address that is not within the range of IP addresses used by any local DHCP server. This prevents the server's IP address from "wandering around". Of course, there are ways to deal with this even when the server uses DHCP (dynamic DNS, etc.), but that requires DNS being handled by a seperate server. It's just a lot simpler on a home network to give the server a fixed IP address.


Fig. 1 Setting a Fixed IP Address for the Server


Fig. 2 Setting the Hostname, Gateway and DNS for the Server

The package selection screen needs to have "Server" and "Server-GUI" checked. You should also consider checking "Packages from Centos Extras", just in case you need to install extra goodies later on.


Fig. 3 Package Selections

That's it for changes prior to installation. Let the installation finish, remove the DVD and reboot the system.

On first bootup after install, you will be asked about the server's firewall. Since this is a server that is on a home network behind an existing firewall, I'm going to disable the server's firewall option. If you were to place this server on your network such that it was exposed to the Internet, then you would definitely need to enable the firewall and do a bunch of security admin to protect the server.


Fig. 4 Firewall Setup after Reboot

Reboot the machine and login as your "normal" user (the one that was specified in the "Create User" dialog on the first bootup. Verify that the networking is running properly (access local machines, surf the web, etc.).

VNC Remote Desktop

Now that the server is running on the LAN, we will want to setup the machine such that we won't need a monitor, keyboard and mouse. We want a nice GUI environment, but we want it available to clients on the network and not to a bunch of hardware physically attached to the server. This saves a bit of energy (by not powering peripherals and a video card).

So, click Applications->Accessories->Teminal to bring up a gnome-terminal window and type "vncpasswd". Type-in a password (it can be different than the system password for the user) and verify. This program creates a ".vnc" directory in your home directory and encrypts your VNC password into a file.


Fig. 5 VNC Password Setup

Next, cd to ~/.vnc. We need to create a startup file for Xvnc to get the Gnome desktop. Type: "gedit xstartup" and type in the following lines:

    unset SESSION_MANAGER
   exec /etc/X11/xinit/xinitrc


Change the file's permissions: "chmod 755 xstartup" and you are done with the user admin of VNC.


Fig. 6 Editing xinitrc in ~/.vnc


Fig. 7 User's VNC Setup Finished

Logout and then login as the root user. We are now going to setup the VNC service on the server for remote access.

Click on Programs->Accessories->Text Editor and edit the file /etc/sysconfig/vncservers. You will see two lines like this:

    # VNCSERVERS="2:myusername"
    # VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -nohttpd -localhost"

VNC can support remote access by multiple users at the same time. Each Xvnc server is given a unique "port offset number". For a single user:

    VNCSERVERS="1:username1"
    VNCSERVERARGS[1]="-geometry 800x600 -nolisten tcp -nohttpd"

For multiple users:

    VNCSERVERS="1:username1,2:username2"
    VNCSERVERARGS[1]="-geometry 800x600 -nolisten tcp -nohttpd"
    VNCSERVERARGS[2]="-geometry 1024x768 -depth 24 -nolisten tcp -nohttpd"

Setup VNC however you wish. You could have VNC access to root, but it's a big security risk and I don't advise it. Access the server as a normal user and then use "su -" to change to the root user in a terminal window instead.


Fig. 8 Editing /etc/sysconfig/vncservers

Server Runlevel and Services

Normally, Centos boots to runlevel 5, which starts up everything including the Xorg server for a desktop environment on a monitor/mouse/keyboard. We are looking to get rid of the monitor/mouse/keyboard, so we'd like the server to boot up to runlevel 3 instead. Login as the root user and then click on Programs->Accessories->Text Editor and edit the file /etc/inittab. You will
see a line like this:

    id:5:initdefault:

change it to runlevel 3 as the default:


    id:3:initdefault:


Fig. 9 Editing /etc/inittab

Click on System->Administration->Server Settings->Services and use the "Edit Runlevel" tab to select runlevel 3. Scroll down and activate "vncserver".


Fig. 10 Starting VNC in Service Configuration

While you are dealing with services, turn off services you don't need and activate any services you'd want to have such as FTP, etc. Save your changes, close the Service Configuration window and reboot the server. You will now come up with just a console, no GUI.

    NOTE: To remove the monitor/keyboard/mouse, you will need to enter
                your
BIOS settings and set "Halt on No Errors", otherwise the
                machine
will Halt when the keyboard is removed.


Fig. 11 Typical BIOS Settings

With VNC running, you should now be able to login from a remote client machine with:

    vncviewer 192.168.0.11:1

and get the Gnome desktop for your normal user. Shutdown the server and remove the monitor/mouse/keyboard and boot. Your are ready for full remote access with a GUI desktop environment.


Fig. 11 The Server's Desktop Seen on a Client