The magazine of the Melbourne PC User Group

Running Your Own Web Server
Roger Brown
 

 


Roger Brown presents Part 1 of an exciting and much needed series on how to set up and run your own Web server

In previous articles on the setting up and use of the ADSL router/modem I covered the basics of how to allow inwards traffic - for server programs that require users from the Internet to connect to your computer. One of the most interesting and useful server projects is to run your own Web server. In other words, to host a Web site on your own PC.

Q: Already I have Web space available through Melb PC and WestNet - why would I want to host my own site?

There are a number of reasons:

  • You avoid the need to upload files - simply place the files in the appropriate folder on your computer and they are automatically part of your Web site

  • You are free from the limitations associated with using ISP-provided Web space. Your ISP can provide only limited disk space - and that can be quickly swallowed up with the multimedia files that are so common these days. With your own site, the only limitation is the size of your hard drive

  • ISP space rarely provides direct server access (other than to upload files). This prevents you from trying out many interesting and useful features that depend upon such access. Site log-in, database access, messaging, guest book, interactive page displays are just some of the interesting additions that your site can incorporate if self hosted. Some of these facilities can be seen in action on my site at http://rogerbrown.no-ip.org.
     
  • And last, but by no means least, it's a fun way to learn.
Q: So what do I need to get started; and isn't it expensive?

Actually the best, and most commonly used, Web server software (Apache) is absolutely free. All you need other than the software, which can be downloaded free, is:
  • A reasonably fast Internet connection (broadband)

  • An ISP that allows the connection to be used for servers (WestNet does, but some other ISPs including Optus do not - check your ISP's acceptable use policy)
So Let's Get Started

We'll begin by installing what must be the smallest and simplest Web server obtainable - the AnalogX Simple Server. Using this tiny but very effective piece of software, you can have a Web page running in 10 minutes flat. It probably won't be your final choice of Web server, but installing it is a great way to get you started on all the steps needed to have a site running and properly accessible.



Figure 1

  1. Go to http://www.analogx.com/contents/download/network/sswww.htm and download SimpleServer. It's a tiny 187 KB.
     
  2. Install the program - the install routine must be simplest you will ever see. Refer to Figure 1.

  3. Create a Web page and save it; you can locate it in any directory. If you don't have a simple HTML editor on your system (the one that comes with Mozilla is ideal), then consider the excellent NVU - see http://www.nvu.com/.

  4. Fire up SimpleServer - it will display the screen in Figure 2.
     
  5. Click the button at the bottom of the SimpleServer window to set your Web directory. Enter the name of the directory where you created and saved your Web page during step 3.
     
  6. Click the Start button

  7. Fire up your Web browser and browse http://localhost. Your page will appear, hopefully it will be a little more elegant than my test page. See Figure 3.



Figure 2

Figure 3


That's all there is to it - your page is fully functional and you can start adding additional pages and content as desired to build your Web site.
 
Q: So, can anyone on the Internet see my site yet?

No, there are a couple of additional steps you need to take for that to happen.
  • First - and especially if you have more than one PC networked to your ADSL connection - you need to give your PC to a static IP address (ie. the same IP address each time you connect). Note that we are talking about your internal network address rather than your public address. See the first of my router articles, PC Update, October 2004, for an explanation of this distinction http://www.melbpc.org.au/pcupdate/2410/2410article8.htm.

  • To set a static IP address in Windows XP follow the instructions at http://www.hotcomm.com/FAQ/FAQ_staticIPXP.asp The procedure is similar for other versions of Windows.

  • Port forwarding. You may remember from my next article that by default, your router will block all inward connections. See PC Update, December 2004 or read it online at http://www.melbpc.org.au/pcupdate/2412/2412article4.htm.

  • Anyone wanting to view your Web site will be making an inward connection (to port 80 - the HTTP or Web server port) and you need to set the router to allow those connections. This is covered in the December article which you can also read online at http://rogerbrown.no-ip.org/router2.html The image displayed in Figure 4, (which is item 7 from the December article) shows how the forwarding is done - the IP address to which port 80 is redirected will be the internal address of the PC running SimpleServer

  • Set your firewall software to allow the Web server to receive connections. If you are not already running firewall software you MUST do so if you wish to run a Web server. I recommend Kerio Personal Firewall Version 2.15 from http://pricelessware.org/thelist/sec.htm. [Ed: Do not underestimate the security risk in opening up your computer to the world-GT]

  • You need a domain name. The steps you have taken so far would enable others to browse your page but only if they knew your IP address. Who wants to browse a site using a URL like http://202.173.154.234? There are a number of ways you can obtain a domain name but a simple and effective one for personal users is to use one of the free DNS services like http://www.no-ip.com. This service (which I use) provides you with a subdomain name (mine is http://rogerbrown.no-ip.org), handles all the details of establishing and maintaining that subdomain name on the DNS system - and does so free of charge! All the details are at http://www.no-ip.com/services/page/free/dynamic/dns.
Now, with those steps out of the way, your Web page (or site) is fully visible on the Internet.
 



Figure 4

Testing External Access

So far, you have viewed your new Web page using the URL http://localhost. That shows it only as it appears on your computer. Any attempt to use your new domain name URL to access the page on your computer will almost certainly not work - that's due to a limitation of your router. So ideally what you want to do is to try and view your page as it would appear on the Internet, and to confirm that your domain name is actually accessible to the world.

Obviously you could do this by having a friend view the page, but you can test it yourself by using an external proxy server. By temporarily setting your browser to use a proxy server, all requests are sent direct to that proxy server which fetches the requested page (in this case from your machine) as if it were fetching it from an external site. It then sends the result back to where the request originated - that's to you. Effectively you are viewing your page in the same way as would any external user. See Figure 5.

A good proxy server to use is the Telstra proxy http://melbourne.cache.telstra.net:3128. Set your browser temporarily to use this proxy. It's even better if (for this test) you can use a second browser (other than the one you normally use). View your page using your chosen domain name URL. If this works, you are definitely visible on the Internet.

 



Figure 5

So What's Next?

Our little SimpleServer, although it is fast and efficient, has limitations. Even though it handles conventional static Web content very well, you won't be able to create the types of interactive effects I mentioned earlier in this article. For that you'll need a more comprehensive server - almost certainly the popular Apache server which according to the May 2005 Netcraft survey http://news.netcraft.com/archives/web_server_survey.html is used for 68% of Internet Web sites. At that point you will also need to install and master a scripting language such as PHP and a database such as MySQL

Detailed coverage of these steps will be in subsequent articles in this series. A good starting point for Windows users is the EasyPHP package - which installs and configures Apache, MySQL and PHP. Download it from http://www.easyphp.org/.

Have fun.

Reprinted from the June 2005 issue of PC Update, the magazine of Melbourne PC User Group, Australia

[ About Melbourne PC User Group ]