Using the Web Test Environment

Once you have your Apache web server installed you’ll want to configure it as closely as possible to your actual web server so that you have a realistic test environment. This will allow you to create and test web pages and applications locally, in real-time, and upload them later.

Contributed by
Rating: 5 stars5 stars5 stars5 stars5 stars / 1
May 08, 2007
Rate this Article:
MEH MEH++


SEARCH ASP FREE
TOOLS YOU CAN USE

advertisement

At this point XAMPP will have installed virtually everything you need.  You can further customize this any way you like.  Don’t use MySQL?  Install the database system of your choice.  Need to add support for Python?  That’s no problem either.

XAMPP installs a lot of useful components.  You should check their web site to see what’s included in the version you installed.  The latest version at the time of this writing even includes Zend Optimizer.  They are constantly adding components to make it as useful as possible.

It should be fairly obvious at this point that your domain is not going to be pointing to this server.  Hopefully you’re accustomed to using relative file paths.  If not, or for any other direct link, you’ll need to substitute http://localhost for your own http://www.yourdomain.com.

Alternatively, you can leave everything the same and add the following entry to your hosts file. (C:WindowsSystem32driversetchosts)

127.0.0.1 www.yourdomain.com

This will redirect all requests for yourdomain.com to 127.0.0.1 which is the address of your local network adapter.

The term ‘localhost’ is actually the hostname assigned to 127.0.0.1.  They can be used interchangeably.

This method is by far the best for cross-compatibility.  You won’t need to change any of the references in your code when you move them between hosts.  The drawback is that you will not be able to access the “live” site at yourdomain.com because your browser will always redirect them locally.

Executing CGI scripts

Getting started with XAMPP, you’ll need to take a few things into consideration.  If you intend to run CGI scripts, you’ll need to know the location of the Perl interpreter.  This will be used in the shebang line of your CGI scripts.  In Linux, you’re probably used to something like this:

#!/usr/bin/perl

On the default XAMPP installation it should be this:

#!/xampp/perl/bin/perl

Of course, you’ll need to make that change in every one of your CGI scripts.

The second thing you’ll need to take into consideration is file/folder permissions.  In Linux you’re used to using chmod to change every file or folder to allow execution.  This is not necessary in Windows XP since all files are given the right to execute by default. (And yes, this is a security risk.)

Apache should already be configured to allow CGI execution when installed with XAMPP.  Let’s double check just to be sure.  Open the httpd.conf file in notepad.  It should be located in C:xamppapacheconf.  Browse through the file until you find the section for your web root directory.  It should look like this:

<Directory "C:/xampp/htdocs">

In that section, you should find an Options line that defines settings for Apache.  Make sure that ExecGCI (and not NoExec) is included.

    Options Indexes FollowSymLinks Includes ExecCGI

Down a little further in the file you’ll find the section that identifies the ScriptAlias.  This is the folder where CGI scripts should be found.  Typically, this is www.yourdomain.com/cgi-bin/ or similar.

The default installation puts this folder above your web root for security reasons.  This is most likely not what you want and it probably won’t work with your current “live” site either.  Just change the path in the ScriptAlias line to a folder under your web root.

ScriptAlias /cgi-bin/ "C:/xampp/htdocs/cgi-bin/"

Now go down just underneath that and change the folder path in the directory declaration.

<Directory "C:/xampp/htdocs/cgi-bin">

    AllowOverride None

    Options None

    Order allow,deny

    Allow from all

</Directory>

If you are not using a standard CGI file handler for your scripts, you can change that in this file as well.  Scroll down a bit more and you’ll find the section for the mime type module.  Locate the line that looks like this:

AddHandler cgi-script .cgi

You can add any extensions you like to have them treated as CGI script by Apache.

AddHandler cgi-script .cgi .pl

PHP switching

XAMPP installs both PHP 4 and PHP 5 by default and allows you to switch between the two.  This is nice because you can use the exact same PHP version installed on your site.

It’s also nice if you’re currently upgrading your code base from PHP 4 to PHP 5.  You can change the code gradually and test under both environments.

To switch PHP versions, you must first stop the Apache service.  You can do that easily by using the Stop button in the XAMPP Control Panel.  Next open My Computer and navigate to your XAMPP installation directory.

Run the php-switch.bat file.  This will ask you to confirm switching versions.  Once you press the number corresponding to the new version, the appropriate files will be moved.

Now go back to the XAMPP Control Panel and restart your Apache service.  Switching back is just as easy.

Allowing external access

You might be setting this server up for internal use by your whole development team.  Perhaps you want to see how your site renders on Mac/IE7 in the cubicle next door.

Anyone in your workgroup can access your web server by default.  They can enter either your network hostname or your network IP address into their browser.  Here are a few examples of how that might look.

http://labpc_mike1

http://192.168.0.7

You may also need to configure any software or hardware firewalls to allow Apache to communicate with other machines.  Typically you will be asked to allow Apache to act as a server or some other similar message.

Okay.  Now what if you want to access this machine from home?  Maybe you’re right in the middle of a project and you want to get some extra work time in over the weekend.

If you are directly connected to the Internet; you are already open to the world.  Anyone with an Internet browser can connect to your web server by using your external IP address.

If you are behind a router or NAT firewall, you will need to enable “port forwarding.”  Log into your router or firewall as per your hardware manufacturer’s instructions and find the settings for either “port forwarding” or “virtual servers” depending on how it’s labeled.

Allow all incoming requests on TCP Port 80 to be redirected to your local IP address. (That’s the 192.168.x.x one.)  Now anyone who accesses your router's or firewall’s external IP address will be able to access your web server.

You can find this IP address by visiting http://www.whatismyip.com/.

blog comments powered by Disqus
BRAINDUMP ARTICLES

- Microsoft Windows 8 Committed to Cloud Compu...
- Independent Developers Favor Windows Phone 7
- Dell Introduces VMware-based Cloud
- Microsoft and Skype Agree to Acquisition Deal
- Transfer Contacts in Microsoft Outlook
- Zune`s Next Steps
- Safari Books Online Review
- Does Microsoft Get Touch Screens Now?
- Microsoft`s Record Quarterly Earnings Not En...
- Basic Operations and Registers in Assembly
- Assembly Coding within Visual C/C++ IDE
- New Microsoft Office Coming with a Twist
- Microsoft`s FUSE Labs Unveils Spindex Social...
- HP Slate with Windows 7: Dead or Alive?
- Windows Phone 7 Mobile OS to Rival Android a...

ASP Web Hosting ASP.Net Web Hosting Windows Web Hosting
 
 
 

ASP Free Forums 
 RSS  Tutorials RSS
 RSS  Forums RSS
 RSS  All Feeds
Site Map 
Request Media Kit
Write For Us Get Paid 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Privacy Policy 
Support 


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 9 - Follow our Sitemap
Most Popular Topics
All ASP.Net Tutorials