DIY Webserver from Scratch

Following on from a post by John Lufadeju on his blog regarding hosting your Wordpress blog locally, and Robert Bravery’s post on using Wordpress on Vista and IIS 7.0 I thought I’d do the geek thing and go one step further and describe how to setup your own dedicated Linux web server (among other services) running Wordpress for home use, and also to let you know that it is not as difficult as it may seem!   I warn you that this post is a long one, but it is bound to be an informative one!

1. Obtaining the Software

Everyone assumes that setting up Apache has to be a nightmare, and requires you to install Linux first, then customise it, then know how to use the command line interface to configure it and and and and…

The above used to be completely true, however quite a few places realised this and started offering all-in-one solutions that are incredibly quick and easy to configure.   My personal favourite has to be ClarkConnect Community Edition, which is now known as ClearOS Enterprise.   This is an open source system, based on Linux, which installs with a wizard, and offers such features as a caching web proxy, firewall, antivirus, antispam, file sharing (even for Windows!), printer sharing, bandwidth management and of course, MySQL and Apache (for a complete list, please check out ClearCenter’s website).

As with most things that are free, there is a catch, albeit not a very big one.   When you install the software, it will be completely active, however to receive software and security updates for your server, you will need to subscribe to ClearSDN, for the whopping price of nothing.   Only if you require corporate support do you pay, and for a home system, its pretty cut and dried that you don’t really need to have an immediate turnaround on support.   Also, if you are simply configuring a webserver, security updates are for the most part completely unnecessary.

So all you need to do, is visit the download page at ClearCenter and download the ISO file.   At 689MB, yes it’s big, but bear in mind its an ENTIRE operating system plus software.

2. Burning the CD

Next step is to burn the ISO to a CD, if you are on Windows 7 this can be done straight off the bat by inserting a blank CD into your drive.   It may be possible to do so in Vista as well, but I am proud to say I only used Vista for about 45 minutes when it came out and then I reformatted my machine and put XP back on.   Failing this, you will need to use something like Nero or Roxio to burn the ISO.

3. Obtaining the Hardware

This is always the expensive part of getting a server up and running (unless you are buying licenses).   If you take a look on Dell’s website, you will be greeted with price tags of over $1,000.   Don’t let this despair you!   ClearOS is really not that hungry, what with being Linux and all that, so you do not need a huge server.   If you don’t have a spare computer tucked away in a cupboard from a few years back, your best bet is to find a company that resells leased equipment that has reached end-of-life, I personally buy through RentWorks.   Here I picked up 2x Pentium 3 1Ghz rackmount servers (I gutted one to make the other more powerful) for the awesome price of R400, which is about $50 US, not bad huh?

An alternate to actually buying physical hardware, is to download VirtualBox, Sun Microsystem’s alternative to Virtual PC (and so much more flexible).   Install this, and you will be able to create multiple virtual PC’s within your own computer.   You can read more about it at VirtualBox.org.   For the record, this is how I will be doing my installation for the purposes of this post.

4. First Bootup

NOTE OF EXTREME WARNING (OR WARNING OF EXTREME NOTE)! INSTALLING ClearOS WILL WIPE OUT EVERY STORAGE DEVICE ON THE COMPUTER IT IS BEING INSTALLED ON (INCLUDING USB AND FIREWIRE)! MAKE SURE YOU ARE USING A SPARE COMPUTER THAT YOU ARE NOT GOING TO MISS ANY DATA ON!

Pop in the CD and boot off it.   The installer is very straight forward in a wizard type format, with every step explained.   You will get to a point where you are asked which mode ClearOS should operate in, Standalone or Gateway.

This is an important bit, if you have 2 network cards in your machine, you can select Gateway mode; what this does is allow you to use this server as a router/firewall/webserver/gateway onto the Internet, so you can actually use the ClearOS box to cache web content (and save you bandwidth!), filter out who sees what and provide you with network security for your home computers.   Should you just wish to host web content for internal testing, then Standalone should suffice.   For this example I am using Standalone.   In Gateway mode, it is worth noting that you can actually expose your server to the web and browse to it, which makes for a nice way of demoing sites to people for other opinions, however this takes a bit more knowledge of networking and IP address configuration.

If you already use a router to connect to the Internet, I would recommend setting your ClearOS machine to use DHCP to obtain its IP address automatically, but if you use a modem and this is the only network computer you have, set its IP address to 192.168.0.1, it will become a DHCP server in that case, and automatically configure your computer!

You will see that once you get to the software modules selection, that this system is quite complete and quite powerful!   With over 20 different modules ranging from VPN to mail to antivirus, you’re sure to be able to do quite a lot.   If you wish to play around, why not select every option?   Selecting all the options will only use around 1GB of hard drive space, so if you have that to play with, it really doesn’t hurt to install everything.   Just follow the on-screen instructions, and if you aren’t sure of something, just go with the defaults.   This system is quite robust, and is pretty difficult to break!

5. Finalising Install

Once the system is installed and you have rebooted, you will come to a red logon screen.   At this point, the system is ready to go.   Make sure you know the box’s IP address before you go back to your normal PC.   When you get back to your PC, open your web browser, and go to https://[your-servers-ip-address]:81/.   This will bring you to a login screen, enter the username ‘root’ and the password you selected in the install to log in.   You will now be guided through a 5-step wizard that will finish off your installation!

You may get a certificate warning when going to the management site, that is only because the certificate is self signed, there is nothing to worry about!

6. Web Management

Here is where the fun starts, you get to manage your server!   For the purposes of this post, I will only be briefly covering the Apache and MySQL portion of it, but as you can see there are MANY options to choose from.   Feel free to go through them and play around!

7. Enabling Apache

From the dashboard of your server, select the ‘Server’ option from the left, and select the ‘Web Server’ sub-option.

From the Web Server option, there are two buttons you now need to select, first select ‘To Auto’, this will start Apache automatically each time the system starts.   Next, select the ‘Start’ button to start the web server.   You will notice that the ‘On boot’ option changes to ‘Automatic’ and the ‘Status’ changes to ‘Running’.

Apache is now enabled!

8. Enabling MySQL

Next, select the MySQL sub-option from the menu on the left.

From the MySQL option, there are two buttons you now need to select, first select ‘To Auto’, this will start MySQL automatically each time the system starts.   Next, select the ‘Start’ button to start the MySQL server.   You will notice that the ‘On boot’ option changes to ‘Automatic’ and the ‘Status’ changes to ‘Running’, as per the web server options.

You will be prompted to enter a database password, do not lose this!

MySQL is now enabled!   (Are you sensing a pattern here as to how easy it is to enable the different services?)

9. Creating the Database

From the MySQL screen, you will see that there is a little notice stating that you can manage your MySQL database through another web interface

Select ‘Go’ to launch phpMyAdmin in a new window (your login username will be ‘root’).   From there you can create your new database from the ‘Create new database’ option.

10. Deploying Wordpress

The easiest way of deploying anything to a Linux server from Windows is to use WinSCP, it is leaps and bounds ahead of FTP as far as security goes.   You can download WinSCP from here (incidentally, it handles FTP as well).   The following install is based on the Famous 5-minute Install.

Next, download the latest version of Wordpress here and unzip it to a folder on your machine.  Navigate to the folder and rename the ‘wp-config-sample.php’ to ‘wp-config.php’.   Edit the wp-config.php file and enter your database details as follows:

  • ‘putyourdbnamehere’ will be replaced with whatever you named your database in step 9
  • ‘usernamehere’ will be replaced with ‘root’
  • ‘yourpasswordhere’ will be replaced with whatever password you chose in step 8

Save the file and close it.

Next, launch WinSCP.   From the initial window, select ‘New’ from the right hand side, then enter your new server’s details and select login.

The first time you log in to your new server, you will get a warning that the server’s host key was not found in the cache, simply select ‘Yes’ to connect and place the host key in the cache.

You will now be greeted with a window similar to most FTP programs.   To get to the web folder, following the following steps in the right hand pane:

  1. Double click the ‘..’ folder
  2. Double click the ‘var’ folder
  3. Double click the ‘www’ folder
  4. Double click the ‘html’ folder
  5. You are now in your website’s root folder (/var/www/html/)

In the left pane, navigate to the location where you unzipped Wordpress, and drag it across to the right hand pane.   A popup will open, select ‘Copy’ to begin.

Now you can navigate to your server’s Wordpress installation by going to http://[your-servers-ip-address]/wordpress/, there you can complete the standard Wordpress installation!

Read the documentation on Wordpress’ site to get a more comprehensive breakdown of installing to a subfolder or to the root.

Conclusion

So there you have it, you now have your own server AT HOME to run any form of staging or muckabout site!   I trust this post was informative and easy to use, I would appreciate any comments regarding it!

4 Responses to “DIY Webserver from Scratch”

  1. Nice long and informative post. Very well done.

    Oh, and BTW, thanks for the Mention and link love. I owe you one.

  2. John says:

    Yes, I know what you mean, the mention of the word Linux scares people to bits ;-)
    You’ve constructed a very detailed setup guide here.
    ClearOS Enterprise appears to be a good all-rounder management system.
    Very tempted to download it….I may just do.

    Thanks for the mention :-)

  3. Wogan says:

    2 suggestions:

    1. Install Wordpress to the root of the server (unless if you’re gong to use the server for other CMSes)
    1.1 Install WPMU instead of Wordpress, though by WP3.0 this’ll be a moot point

    2. Edit your hosts file to map that IP to a manageable name, so that:

    http://192.168.56.101/wordpress/index.php

    becomes:

    http://wordpress/index.php

    Windows instructions: http://geekswithblogs.net/thibbard/archive/2006/12/13/ChangingYourHostsFileInVista.aspx (Dunno about Mac/Linux)

    3. Profit!

    ~ Wogan

    • Ross says:

      Thanks Wogan! I agree on installing Wordpress to the root of the server if its the only thing there, however for simplicity’s sake I opted for leaving it in the default folder from the extraction for the purpose of the article. I will definitely look into WPMU, wasn’t aware of it at all (only been learning WP in the last 4 months or so), love the homepage feature of “Ambiguity about how to pronounce its name”!

      Thanks as well for the hosts file link, think I may just add another article on it here for multiple OS’s as I did with the little IP address post. :P

 

Leave a Thought or Inconsistency

 

 

 

 

 

Switch to our mobile site