How to Build a Home/Small Business Web Server in no Time
by Liam McDermott, 19 September 2008 - 10:45am
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:
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.
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 Name||Domain Name|
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 Partitioning||Select Disk||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.
|Root User Password||User’s Full Name||Username||Password|
Another short wait is required, while the base system is installed. Online updates will be enabled in the next step.
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 Mirror||Mirror Location||Select a 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 Contest||Software Selection||GRUB Bootloader||Installation Complete|
Logging in for the First Time
|Server Login Prompt|
Stop the Installer Prompting for the CD
Unless stopped, the server will try to install software from the CD. Fix this by typing:
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:
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:
Find the section that looks like:
# The primary network interface
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
#iface eth0 inet dhcp
iface eth0 inet static
As before, save and exit by pressing: Ctrl-x, followed by y then Enter. Now type:
127.0.0.1 localhost.localdomain localhost
192.168.0.200 dave.intermedia.local dave
echo dave.intermedia.local > /etc/hostname
Then restart the server by typing:
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):
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.
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:
chmod +x 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:
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/.
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.
Discuss setting up a small business Web server on the forums.