How to Build a Home/Small Business Web Server in no Time

This article goes through a quick and easy process for building a home or small business web server. The finished server will have Web server software, PHP, Perl, Ruby, MySQL, PostgreSQL, quotas, e-mail server software, anti-spam and anti-virus software, and a lot more good stuff. To top it off it will have a Web based GUI to control it all. Read on to learn how.

Download and Burn a Debian CD

Debian GNU/Linux is the basis of the server. It can be downloaded for free, from the Debian Web site. Select a download from the ‘Small CDs’ section, the list of architectures — [alpha][amd64] and what not — can be confusing. If in doubt click the [i386] link to get a CD image that will work on most machines, shown in the screenshot below:

Debian download page

Once the download is complete, the file needs to be burned onto a CD. This is easy in Ubuntu (or any other GNU/Linux desktop) and a little more tricky using Windows. In Ubuntu, right-click on the downloaded file and select Write to Disc...

Windows and Mac users should follow these instructions for burning a CD image (but instead of Ubuntu, burn the debian .iso file just downloaded instead).

Booting from the CD

Next ensure the server computer is set to boot from CD (generally this means changing a BIOS setting, and varies by computer. Check the computer’s documentation, or do a search for more help with this). Put the CD into the CD-ROM drive and restart the computer. When the screen below appears press Enter.

Debian splash screen

Beginning the Installation and Configuring Networking

The installer will then ask some simple questions on location and language, answer these and wait for the next prompt.

The Host Name prompt is for entering the name of the server, this can be anything. Some IT departments have naming conventions (Greek gods for example), but something as simple as webserver will do.

Domain Name is next, the server being setup in this article is for internal use only, so the domain name has been set to apaddedcell.local to avoid interference or confusion with an Internet-facing server. If the server were built to be Internet-facing, i.e. serving an actual site, it would have a recognised domain name such as apaddedcell.com. In summary: if the server is for an actual domain on the Internet, use that domain name for this step, otherwise any domain name can be used.

Host NameDomain Name
Host name selection Domain name selection

Partitioning

Then the installer needs to know how to partition the hard drive. In most cases the default settings are correct, so press Enter at each of the next four steps.

Start PartitioningSelect DiskPartitioning SchemeFinish Partitioning
Partitioning the hard drive Confirm partitioning Partitioning scheme Finish partitioning

Just to be sure, a final confirmation is shown. Answer Yes to continue. There is then a short wait while the partitions are created.

Usernames and Passwords

The installer will ask for a Root User Password. The ‘root user’ is an account setup for the server administrator, and should only be used for tasks that need the access.

Then a standard user account is created, your own details can be used here. Enter the User’s Full Name, followed by a short Username and a Password.

Root User PasswordUser’s Full NameUsernamePassword
Setup the root user password Setup normal user Normal user username Normal user password

Another short wait is required, while the base system is installed. Online updates will be enabled in the next step.

Online Updates

Answer Yes to the Network Mirror prompt — note: this article assumes an Internet connection for the server is available.

A list of countries will then appear (Mirror Location), select the nearest one (if it isn’t already selected) and press Enter. Press Enter again to continue through the next prompt, to Select a Mirror.

At the HTTP Proxy prompt it’s unlikely that anything needs to be filled in. In the unlikely case that an HTTP Proxy is needed to access the Internet, enter its address and press Enter. Otherwise leave the text box blank and press Enter.

Network MirrorMirror LocationSelect a MirrorHTTP Proxy
Connect to online mirror prompt Online mirror location Select exact online mirror HTTP proxy

Completing the Installation

Press Enter to get past the Popularity Contest prompt. Under Software Selection, use the space bar to uncheck the Desktop environment option, leaving only the Standard system selected. Press Enter to start downloading and installing packages.

Answer Yes to the install GRUB Bootloader prompt — note: this article assumes the only OS on the server is the one being installed now, this might not be the correct choice for all setups.

When Installation Completes a prompt will offer to restart the newly installed system, remove the CD from the drive and press Enter to restart.

Popularity ContestSoftware SelectionGRUB BootloaderInstallation Complete
Taking part in the popularity contest Software selection Install the GRUB bootloader Completing the installation and restarting

Logging in for the First Time

When the Server Login Prompt appears, after the restart, type root. Then type the password given earlier, at the Root User Password prompt.

Server Login Prompt
New system started up

Stop the Installer Prompting for the CD

Unless stopped, the server will try to install software from the CD. Fix this by typing:

nano /etc/apt/sources.list

Find the following line (this may change slightly when a new version of Debian is released, just look for the line starting deb cdrom:):

deb cdrom:[Debian GNU/Linux 4.0 r4a _Etch_ - Official i386 NETINST Binary-1 20080804-15:10]/ etch contrib main

Add a # at the start of the line, so it looks like this:

#deb cdrom:[Debian GNU/Linux 4.0 r4a _Etch_ - Official i386 NETINST Binary-1 20080804-15:10]/ etch contrib main

Save and exit by pressing: Ctrl-x, followed by y then Enter. Now type the following command:

apt-get update

Remote Access (using SSH)

Instead of working at the server, it is much easier to access it from a laptop or desktop remotely (although this can be taken too far: server admins taking their laptops into the lavatory, for example). Type:

apt-get install ssh openssh-server

When asked Do you want to continue [Y/n]? press Enter. Wait for the installation to finish, then type:

nano /etc/network/interfaces

Find the section that looks like:

# The primary network interface
allow-hotplug eth0
iface eth0 inet dhcp

Then change it to the following, these settings may have to be changed according to the network setup (particularly the address and gateway, type route -n at the command line to find out the latter):

# The primary network interface
#allow-hotplug eth0
#iface eth0 inet dhcp
auto eth0
iface eth0 inet static
  address 192.168.0.200
  netmask 255.255.255.0
  network 192.168.0.0
  broadcast 192.168.0.255
  gateway 192.168.0.1

As before, save and exit by pressing: Ctrl-x, followed by y then Enter. Now type:

nano /etc/hosts

Change the first section (but ignore the IPv6 section) to reflect the Host Name, Domain Name and address (in /etc/network/interfaces) settings entered earlier. It should look similar to this:

127.0.0.1 localhost.localdomain localhost
192.168.0.200 dave.intermedia.local dave

Now set up the hostname by typing the following (replace dave with the Host Name and intermedia.local with the Domain Name entered earlier):

echo dave.intermedia.local > /etc/hostname

Then restart the server by typing:

reboot

Now the server can be accessed by another computer on the network. In Ubuntu, click Applications -> Accessories -> Terminal, then type (and enter the root user password when prompted):

ssh root@192.168.0.200

Windows users will need to download PuTTY.

The advantage of remote access is twofold: firstly, it means the work does not have to be done physically at the server, and secondly, commands can be copied from this article and pasted onto the command line (much less typing). If possible, follow the rest of the article using SSH to remotely access the server.

Install VirtualMin

VirtualMin is a free control panel for GNU/Linux servers. It includes everything needed to run a Web server: PHP, Perl, Ruby, MySQL, PostgreSQL, quotas, e-mail server software, anti-spam and anti-virus software, and much more. Install it by copying and pasting the following commands:

wget http://software.virtualmin.com/gpl/scripts/install.sh
chmod +x install.sh
./install.sh

Press y, then Enter to start the installation (this will take a few minutes). The only thing needed are some add-ons for php that allow it to access mysql and a few other things. Copy and paste this to the command line:

apt-get install php5-mysql php5-pgsql php5-gd

When asked Do you want to continue [Y/n]? press Enter.

Now view the newly installed VirtualMin. Open a Web browser and enter the URL: https://192.168.0.200:10000 (change the IP address according to the address in /etc/network/interfaces). Then enter root in the Username, and the corresponding root user password.

Setting up a domain

With all software installed, the next step is to create a domain. See the Virtualmin video introduction — although the automatic software installation shown in the video is only available in the commercial version.

A Note on Domain Names

If this server is being used for internal development, then the Domain name entered when creating a Virtual server (in Virtualmin) will need to be pointed to the server. This is done by editing the hosts file on each client computer. For a server with an IP address of 192.168.0.200, and a domain name of site.webserver.local the following should be added to the hosts file on the client computer:

192.168.0.200  site.webserver.local

See these instructions on editing the hosts file. Then try it by opening a Web browser and entering the URL: http://site.webserver.local. If that doesn't work, make sure there is an index.html uploaded to the server. Hint: this can be done with FTP, using the user name and password entered when the Virtual server was created. Virtualmin stores Web site files in /home/*Virtual server name*/public_html/.

VirtualMin Support

For those who need enterprise grade support, this package is also available under a commercial license (keep the PHB happy), with support. Products are shown at the online shop.

References

Discussion

Discuss setting up a small business Web server on the forums.

About the Author

Liam McDermott is the technical bod at The Webmaster Forums. He also writes articles and loves dallying with Drupal. His business site is InterMedia.