How to install a personal web server

We'd recommend selecting the OpenSSH Server and LAMP Server as a good starting configuration. OpenSSH is one of the most powerful tools available for Linux because it lets you access the command line securely from any remote location, as long as port 22 is forwarded to your machine through any firewall. It also means that you can disconnect the keyboard, mouse and screen after you've set up your server machine on your local network, because you'll be able to do everything else using a remote SSH connection.

You've probably heard of LAMP. It stands for Linux/Apache/MySQL and PHP, and these four technologies have helped transform the world wide web for companies like Facebook and Twitter.

Apache is the web server itself, allowing you to host sites and for them to be accessed from across the network.

MySQL is a database server, commonly used by the likes of Wordpress to store things like posts, comments and forum chatter. It might sound a little 'enterprise' to be installing something like this on your humble server, but it's a service that runs well on slower machines and can scale to meet your needs.You can give the installer a root password for this, which we recommend if you're going to use it online.

PHP is the programming glue that binds this together. Don't let talk of programming put you off, though. You usually install pre-baked PHP packages rather than coding your own solutions, so you'll never need to touch the code.

Port forwarding

With your servers selected, continue with the installation. After a few minutes, the final question will ask whether you want to install the Grub boot loader into the master boot record. You should select 'Yes' unless you're running your server alongside a Windows installation. You'll then be able to restart your machine and remove the bootable disc.

After restarting, you won't see a desktop or graphical login screen. Instead you'll see a monochrome command prompt asking you to log in. Use the account credentials you created from the installer to log in, and you'll find yourself at the command line.

We first want to discover the IP address of the server, and this should be displayed as part of the login overview you see above the command prompt. Look for the line 'IP address for eth0'. This IP address is important because you want to run your machine as a server. On most networks, it will be given to your machine by a DHCP server running somewhere on your LAN, usually tucked away on your router or modem. Most of the time this address will be the same, but there's no guarantee because it's allocated dynamically according to demand.

With the server up and running, the easiest solution for most routers is to use its web interface to give our Ubuntu server a static address. Each router is different, so we can't provide instructions, but the task is usually straightforward.

While you're in the web interface, you will also need to open a couple of ports in your firewall and then forward these to your Ubuntu server. These ports will depend on which servers you're running, but for a web server and OpenSSH, it will be ports 80 and 22 respectively.

Check out the server

Apache works

This is all the configuration that's needed. You can now point a browser at the internet-facing IP address provided by your ISP, or your server's IP address on the LAN. The infamous 'It works!' message will be delivered by Apache.

Your server is now ready for your web masterpiece. This isn't the place for a tutorial on HTML or PHP, but the /var/www/index.html file is a good place to start, because this is what's read to create the 'It works!' messages served by Apache. Edit this file and your website changes.