Bedroom Servers

Every one should have one of these servers, it’s got folder and cd drive sharing (Samba), ssh capabilities, a development web server (Xampp), a private IRC chat network (oftc-hybrid), and and OpenVZ server. In this how to I’ll walk you through setting up one of these servers, but please note I will not cover any items of major security, this is up to you to decide how to lock down your computers. My server is running Ubuntu 9.04 and all the commands that I give will be fore Ubuntu and all the menus will be for Gnome. This How To assumes you have a good idea of how to use the Linux terminal, enough that you can manage a system that has no GUI such as Gnome or KDE. It also assumes that you have Ubuntu 9.04 installed, internet access for installing the programs (and reading this), and time. Finally, it assumes that you will do your own research into these packages, and know how to use and configure them properly for your need; this How To will provide you with a basic configuration of some files, just enough to get your server up and running without much problems. A) I installed openssh-server so I could log in and manage my server from my laptop, you may want to do this if the machine will be stuck in a hard to get to corner. More information about openssh and ubuntu can be found here: ssh help B) After booting into your server, either open a terminal [Applications -> Accessories -> Terminal] or use [ ctrl + alt + F1] to get to tty1. You’ll do most of, if not all the work in this terminal. 1) Lets get started. First we’ll install Xampp; Xampp is an easy to use package of Apache, PHP, MYSQL and ProFTP. instead of installing and configuring all this software individually, we’ll save a bit of time and have most of the hard work done for us. In the terminal, type:

 wget http://www.apachefriends.org/download.php?xampp-linux-1.7.2.tar.gz  sudo tar xvfz xampp-linux-1.7.2.tar.gz -C /opt  sudo /opt/lampp/lampp start 

This downloads, and unpacks xampp to /opt/lampp, and starts it. You can now navigate to “localhost”  in your web browser, choose a language and get started. For some added support for the end product of the server, you could make a homepage for your network that has links and some information on the FTP and Samba. I have both eyeOS (an open source web os) and CGI:IRC (a perl based IRC web client) to add some support to my network as well. You can find more information about Xampp here: Xampp 2) Installing the IRC network. I’ll be using oftc-hybrid for my IRC server, I’ve tried a few IRC server packages, and found that this one stays up the longest and needs the least configuration for my server.

 sudo apt-get install oftc-hybrid  sudo invoke-rc.d oftc-hybrid start 

If you need to restart the server, just replace

start

with

restart

You may also not need to do the second command until after you reboot. To configure the server, take a look at /etc/ircd-hybrid/ircd.conf and to change the motd look at /etc/ircd-hybrid/ircd.motd. I have CGI:IRC installed on my web server (Xampp) so I can access the IRC network from any computer in my house. 3)Next we’ll install and do a small bit of configuring of Samba.

sudo apt-get install samba

sudo /etc/init.d/samba stop

sudo mv /etc/samba/smb.conf /etc/samba/smb.conf.template

sudo touch /etc/samba/smb.conf

sudo gedit /etc/samba/smb.conf

When gedit opens, copy and paste the following:

[global]
; General server settings
netbios name = YOUR_HOSTNAME
server string =
workgroup = YOUR_WORKGROUP
announce version = 5.0
socket options = TCP_NODELAY IPTOS_LOWDELAY SO_KEEPALIVE SO_RCVBUF=8192 SO_SNDBUF=8192
passdb backend = tdbsam
security = user
null passwords = true
username map = /etc/samba/smbusers
name resolve order = hosts wins bcast
wins support = no
printing = CUPS
printcap name = CUPS
syslog = 1
syslog only = yes

[Mounted Media]
path = /media
browseable = yes
read only = yes
guest ok = yes

[MyFiles]
path = /media/samba/
browseable = yes
read only = no
guest ok = no
create mask = 0644
directory mask = 0755
force user = YOUR_USERNAME
force group = YOUR_USERGROUP

And change the settings as needed to fit your server.

sudo chmod 0777 /media/samba

sudo /etc/init.d/samba start

sudo smbpasswd -L -a your_username

sudo smbpasswd -L -e your_username

For the last two lines, replace your_username with, well, your user name on the server (the password that it'll ask for should be the same as your login password). Some more information on configuring Samba: Ubuntu Forums. 4) The final thing to install is OpenVZ. OpenVZ is os level virtualization, and can be used to setup VPS for web servers. This install took the most head banging and time out of all of these I have talked about. Because OpenVZ isn't made for debian based systems, ubuntu doesn't have everything in the reposistories and as a result we'll have to download and use the port for debian off of the debian servers.

sudo apt-get install vzctl vzquota

wget http://ftp.fr.debian.org/debian/pool/main/l/linux-2.6/linux-image-2.6.26-2-openvz-686_2.6.26-17_i386.deb

sudo dpkg -i linux-image-2.6.26-2-openvz-686_2.6.26-17_i386.deb

sudo ln -s /var/lib/vz /vz

#the next bit is if you want the “containers” to have networking.

sudo apt-get install bridge-utils

Reboot after this is all done, and boot into the openvz kernel. Next we'll make a test server and configure networking. The OS that I will use on this container is CentOS 5. Do not unpack the tar.gz that will be downloaded.

wget http://download.openvz.org/template/precreated/centos-5-x86.tar.gz

sudo cp ~/centos-5-x86.tar.gz /vz/template/cache

sudo gedit  /etc/network/interfaces

When gedit opens, copy and past this into it. Please change the eth0 if your card is not eth0 (use

ifconfig

to find out)

auto lo
iface lo inet loopback

brctl addbr br0
auto br0
iface br0 inet dhcp
bridge_ports eth0
sudo /etc/init.d/networking restart

Now lets make a CentOS 5 container. When you do

sudo vzctl exec 1 passwd

You will be prompted to enter a new unix password. This is the password for your new CentOS container. You can use

exit

once inside the container to exit back to your machine. More help here: OpenVZ Help

sudo vzctl create 1 –ostemplate centos-5-x86 --config vps.basic

sudo vzctl set 1 --hostname HOSTNAME --save

sudo vzctl set 1 --ipadd IP_ADDRESS --save

sudo vzctl set 1 --numothersock 120 --save

sudo vzctl start 1

sudo vzctl exec 1 passwd

sudo vzctl set 1 --netif_add YOUR_CARD --save

sudo  brctl addif br0 veth1.1

sudo vzctl exec 1 dhclient YOUR_CARD

sudo vzctl enter 1

Thats it! You should now be able to log into your new container from both the host node (your server) and via ssh on your local network. You can get more container templates at: Templates 5) There is no number 5 in this How To, it's now up to you to secure your system if needed, and add more functionality to your server. When you reboot your server, you may need to do:

sudo ./opt/lampp/lampp start

sudo smbpasswd -L -e your_username

sudo invoke-rc.d oftc-hybrid restart

to get all the services up and running again. Some things you may want to add to your server may be a Git repository, or services to the IRC server.

One thought on “Bedroom Servers

Comments are closed.