Localhost: Building & Testing Websites On A Local Machine
While the world may be waiting for your latest and greatest website there’s nothing like testing it locally for smoothing out the wrinkles or just getting to know how the process works. In this article I’ll take a look at ways you may want to do this.
In the main the article focuses on general web technology but it does include brief notes on an IIS installation.
IIS is the Microsoft webserver and allows you to run legacy .asp websites. IIS is included in the Windows installation but it is not installed by default. The latest version of IIS on Windows 7 or Windows Server 2008 is IIS 7 and is installed by choosing Programs from the Control Panel. Rather than reinvent the wheel I’ve provided a how to install IIS 7 link that outlines the steps involved.
Xampp is a self-contained development environment and includes the Apache Web server, a MySQL database and support for Perl and PHP scripting. The Apache webserver will not run legacy asp code or .Net applications without adding extra modules.The easiest way to install it is to download the latest version and follow the instructions. If you are installing on Linux follow the extremely easy instructions on the XAMPP site.
In my own experience it is on Windows where problems tend to surface.I’ve an earlier post telling you how to do this.
Possible XAMPP problems: Port 80
If you have software like Skype installed it takes Port 80 if it is not already assigned. This means your Apache Web server will not start. The simplest fix is to shut down Skype or any other software, then start Apache. Alternatively you can just change the default port in Skype and restart Skype. XAMPP Perl errorsIf you have Perl installed independently and you are getting errors you will need to change the path at that top of your Perl file.
Change it from the default#!/usr/bin/perl
to the path location of Perl inside XAMPP#!c:xamppperlbinperl or #!c:/xampp/perl/bin/perl
This assumes you chose the default location. If not replace the path with your own in the line above.
Replication of your site
Make sure that you create your site exactly as you expect users to view it live. This means exact directory structures and the locations of files. This makes transfer of the site to a live server far less problematic as well as no unnecessary searches for missing files.
While differences remain in how browsers display data it is essential that you install any browsers you expect users to have. Of the many available the top 5 should suffice for most development. This will be Internet Explorer(Multiple versions, which may even include a need for IE7), Mozilla Firefox, Google Chrome, Opera, Safari and possibly Konqueror for Linux.
You should also consider how your site will look to users of mobile devices – Google has indicated how important this is now – and use an emulator to evaluate this. The Opera Mobile Emulator should give you some scope to test this. There are other emulators available online that will allow you test individual device types.
While you can use the likes of Firebug to help in overall testing there is no harm in forcing your dynamic web pages to display errors by adding code to each file to alert you to syntax errors.
Add this to each PHP file after the opening <?php tag.ini_set(‘display_errors’, 1);error_reporting(E_ALL);
In Perl we can trap errors by using the die() command.Don’t forget to remove any debugging code before going live.Above all be happy when you find a bug as it is one less that visitors will find.
Paranoia is often the best tool when it come to web security. If your site will involve logins and storage of IDs and passwords security must be a core part of any development. A tool like Vega can analyse your code and help you identify possible problems such as potential risks to your database. You can also help by limiting what users can do apart from what you will allow them to do.
Creating a local version is a chance to break a site and also an opportunity to test new ideas and make sure that fewer bugs show up in a live site. It’s certainly a good opportunity to improve on coding skills and development practices that can often end up lost in the need to address real world problems that occur with web sites.