Assuming you have read the previous article entitled ‘The pros and cons of running a home web server‘, this article forms the next section of the tutorial, taking the Debian route.

What is Debian: Debian is one of the oldest Linux distributions that is still maintained to this day, the main focuses of the Debian project are security and stability; these two properties help to make a good web server.

For the use of this article I am performing two installs, one on an IBM Thinkpad T20; Pentium III 700Mhz, 512MB RAM, 20GB HDD. The other is being installed on a ‘virtual machine’ to allow me to create clear screen shots of the installer screens.

Assuming you have already chosen your desired computer for use as a web server you will now want to download the desired Debian installation disc, this article is based on the NetInstall image, depending on your computer you will either want to download the i386 ISO or the amd64 ISO, if you are unsure of which one you require the i386 ISO is a safe choice. Download Debian NetInstall ISO. Once downloaded burn the ISO image to a CD-R disc ready to boot your new web server from (You may need to change the boot settings in your computers BIOS to allow you to boot from the Debian NetInstall CD.)

Turn on your computer and boot the Debian NetInstall CD, you will be greeted with the following:

Debian-server01

Select install from the menu using the arrow keys and pressing ‘Enter’.

Debian-Server02

Select your desired language, in my case ‘English – English’.

Debian-Server03

Select your physical location, in my case ‘United Kingdom’.

Debian-Server04

Select your keyboard layout, in my case ‘British English’.

Debian-Server05

Debian will now load some required resources and configure certain hardware ready for the installation.

Debian-Server06

Enter a host name for your server, this can either be the first part of the domain name you wish to host i.e. for ‘domain.com’ you would enter ‘domain’, alternatively you can name your web server something like ‘myserver’.

Debian-Server07

Enter a domain name for your server, this can either be the second part of the domain you wish to host i.e. for ‘domain.com’ you would enter ‘com’, alternatively you can give your web server the domain of ‘lan’.

Debian-Server08

Enter  password for your ‘root’ user, ensure this password is secure as the root account has access to alter any part of your web server. When you press enter you will be prompted to re-enter the password to ensure there were no typo mistakes.

Debian-Server09

The installation will now create a non-root user account, to begin with enter your server admin’s name.

Debian-Server10

Enter the desired username for the new account, this will default to your users first name.

Debian-Server11

Enter a password for your new user account. When you press enter you will be prompted to re-enter the password to ensure there were no typo mistakes.

Debian-Server12

The Debian installer will now load the partitioner, although guided partitioning will be sufficient for a basic home web server it is always useful to know how to partition a hard drive for linux. Select ‘Manual’ to continue.

Debian-Server13

You will be shown a list of hard drives installed into your computer, in this instance only one drive is present. Highlight the desired hard drive and press Enter.

Debian-Server14

If there are unwanted partitions on the hard drive, highlight them and press enter, then select the option to remove the partition. To create a new partition highlight the free space underneath the desired hard drive and press Enter.

Debian-Server15

Select ‘Create a new partition’

[image 16]

Change the value to 1GB, this will eventually form a swap partition which is used when the computers R.A.M is running low.

Debian-Server17

Select ‘Logical’ for the swap partition.

Debian-Server18

You may chose to have the swap partition at the beginning or end of the hard drive, my personal preference is at the end.

Debian-Server19

Select the ‘Use as’ option for the new partition and press Enter.

Debian-Server20

Select ‘Swap area’ from the list.

Debian-Server21

Select ‘Done setting up the partition’ to continue.

Debian-Server22

The partition table will now show the newly created swap partition below the desired hard drive. Again select the free space below your desired hard drive and press Enter.

Debian-Server23

Select ‘Create a new partition’

Debian-Server24

For simplicities sake I will create this article with a single partition. You may create the largest possible partition size depending on the size of your hard drive.

[image 25]

Select ‘Primary’

Debian-Server26

Select ‘Done setting up this partition’ to continue.

Debian-Server27

The two partitions required have now been created, select ‘Finish partitioning and write the changes to disk’.

Debian-Server28

Confirm the changes to be written.

Debian-Server29

After the partitioning has been completed Debian will automatically install the base system.

Debian-Server30

Select the closest location to help select the fastest mirror server.

Debian-Server31

Select the desired mirror server to use, in my case I have selected Mirrorservice.org as their servers are hosted at the University of Kent, around 20 miles from my home.

Debian-Server32

If your internet connection requires the use of a proxy server enter the information here, most home networks will not require the use of a proxy server.

Debian-Server33

Debian will now set up the apt service which is used for installing software from a mirror server and download lists of available software.

Debian-Server34

Decide if you wish to participate in the package usage survey.

Debian-Server35

Deselect all software except for ‘SSH Server’, note you select and deselect software using the space bar, pressing enter will confirm the selected packages and install them.

Debian-Server36

Select yes to install the GRUB boot loader to the master boot record.

Debian-Server37

The base installation is now complete. Select continue to reboot your computer into the new Debian install, ensure you remove the NetInstall CD before your computer boots up again.

Debian-Server38

When your web server has rebooted, proceed to log-in using the root account.

Debian-Server39

The default Debian install uses a dynamic IP address on your home network, ideally a web server should be using a static IP address that will stay the same after reboots. Type the following command to edit the network settings.

nano /etc/networking/interfaces

Debian-Server40

The dynamic settings will look like those above.

Debian-Server41

On the last line of text change ‘iface eth0 inet dhcp’ to ‘iface eth0 inet static’. Add the following information on the lines below, changing the IP addresses to match those of your home network:

address    192.168.1.230
netmask   255.255.255.0
gateway   192.168.1.254

To save the file press [CTRL + O] (to output the file), press enter to keep the name the same and overwrite the data, finally press [CTRL + X] (to exit nano)

Restart your web server with the command ‘shutdown -r now’, this will restart and load up the new network settings.


The next part of the installation process can be performed from another computer using a remote connection called SSH, in order to do this we will need to install an SSH client (for example Putty) on the remote computer. Note most Linux distributions are capable of connecting via an SSH terminal program, I still prefer to use putty.

Debian-Server42

Open your chosen SSH client (for example putty), and enter the local IP address for your web server (in our example this was 192.168.1.230) and click ‘Open’.

Debian-Server43

Log into your web server using the ‘root’ account

Debian-Server45

To install the LAMP (Linux + Apache + MySQL + PHP) server type the following command

apt-get install apache2 mysql-server php5 php5-mysql

This will install: Apache web server, MySQL server & the PHP programming language.

Type ‘y’ to confirm the installation.

Debian-Server46

During the installation of MySQL server you will be prompted to enter a MySQL root password, this can be the same as your ‘root’ password or something new.

Debian-Server47

To test the installation of the Apache web server open a web browser and enter the IP address in the URL field (in our example 192.168.1.230). If the Apache web server is installed correctly you will see the ‘It works!’ message.

Debian-Server48

To test the PHP installation we will create a test PHP script in the web servers directory of /var/www/. Type the following to create a test PHP script.

nano /var/www/index.php

Debian-Server49

In the new file created type enter the following:

<?php

phpinfo();

?>

followed by [CTRL + O] to save the file and [CTRL + X] to exit nano.

Debian-Server50

Back to the web browser enter the IP address followed by ‘/index.php’ for example ‘192.168.1.230/index.php’. If PHP has installed successfully you will see the PHP information screen.


You now have a fully functional local web server running the Apache web server, MySQL server and PHP programming language.

Previous