Dynamic Solutions

Unless you have a very simple Web site, chances are that you will have some dynamic elements to your Web site. Server Side Includes are a simple way to introduce regularly occurring elements and even dynamic elements into your Web pages.

Irrespective of the development language you have used in the past and how compatible it is across platforms, you should expect to have to make at least a few changes when migrating applications from Unix to Windows.

Even if you've used the built-in tools that manage file naming and location issues or the generic network tools, you might still need to make allowances. Also, keep in mind that many extensions beyond the core language will require recompilation or resourcing to work within the Windows environment. A good example here is the DBI extensions used for connecting to databases in Perl.

Remember that if you are using CGI or ISAPI methods, you will need to enable them through the Web Service Extension manager within the IIS MMC snap-in. You can see an example of the manager in Figure 8.6.

Figure 8.6. Adding and configuring Web service extensions.


Once you've added a particular ISAPI filter, you configure the extensions that work with individual filters?equivalent to the Apache AddHandler directive?through the Directory or Home Directory properties page for a directory or Web site. You can see the page in Figure 8.7.

Figure 8.7. Configuring applications and handlers.


First, set the Execute permissions to scripts only. Then click the Configuration button to get the mappings window shown in Figure 8.8. This enables you to associate a given file extension with one of the registered ISAPI filters. You can see from the figure, for example, that .pl uses Perl in CGI mode and .plx uses Perl in ISAPI mode.

Figure 8.8. Associating extensions with ISAPI filters.


Server Side Includes

If all you need is some basic template building and importing of different elements into a page, the obvious choice is usually Server Side Includes (SSI). SSI is processed directly by Apache and is therefore a much more efficient model than using Perl or Python in CGI mode (that is, without the benefit of mod_perl).

You can enable server side includes using the server extensions manager within the IIS MMC snap-in.

graphics/does_icon.gif SERVER-SIDE INCLUDES

Remember that SSIs are one way that hackers attempt to attack some Web sites, which is why IIS disables them in a default installation. You will need to specifically enable SSIs in Add/Remove Windows Components before they will be available to you.


Perl is available on the Windows platform in both original and ActivePerl editions. The ActivePerl Edition, from ActiveState Corporation, includes extensions that enable it to work as an ISAPI filter. The standard installer will correctly install and configure your IIS installation to execute Perl scripts just as if they were CGI scripts under Apache/Unix.

In most instances, the ActivePerl route is the easiest one to take. You should be able to transfer your existing scripts?and any modules and other elements that the scripts need?to your new IIS host, and they should continue to execute normally.

ActivePerl version numbers use the same version numbering system as the main Perl distribution. In addition, ActivePerl gives a 'build' number that indicates the specific build (incorporating new features, enhancements, and bug fixes). For example, the full ActivePerl distribution can be referred to as ActivePerl 5.6.1, Build 631. You should always choose the latest 'stable' build of the ActivePerl distribution.

If you want a faster solution, you can essentially embed the Perl interpreter into IIS using PerlEx, which is also from ActiveState. The embedding provided by PerlEx is similar to the functionality provided by mod_perl, although unlike mod_perl, it's limited to execution of Perl scripts, not a general-purpose extension for using Perl within Apache.


At the time of writing, support for PerlEx in IIS 6 in Worker Process Isolation Mode was uncertain?although it appears to work correctly when used in IIS 5 Isolation Mode.

For more extensive installations in which you want you take full advantage of the Windows platform, you might want to consider PerlASPX, again from ActiveState. PerlASPX is a Perl interpreter built on top of the .NET Framework that enables you to use .NET technologies from within a Perl script. As an ASP.NET service, it offers the best of both worlds?compatibility with your existing Perl applications combined with the capability to interface to the newer features supported by .NET.

For the development environment, you might want to consider VisualPerl, which is an extension to the Visual Studio.NET development environment customized for developing Perl applications. You get the same benefits as other target languages?inline debugger, customized editors, class browsing, and source code control.


Python is also available in a Windows version, and fewer compatibility issues exist when migrating from one platform to another?provided that you've used the generic underlying modules for file naming, network connections, threads, and so on.

ActiveState also provides versions of Python for Windows in the form of ActivePython and a Visual Studio.NET component in the form of VisualPython.

You can obtain the ActivePython software?a special version of the Python language interpreter designed to work under Windows and with additional Windows specific extensions?by downloading the ActivePython installer from the ActiveState Web site.

ActivePython version numbers use the same version numbering system of the main Python distribution. In addition, ActivePython gives a 'build' number, which indicates the specific build (incorporating new features, enhancements, and bug fixes). For example, the full ActivePython distribution can be referred to as ActivePython 2.2.0, Build 221. You should always choose the latest 'stable' build of the ActivePython distribution.


PHP is also a cross-platform capable Web programming language. An installer is available that includes ISAPI support for the IIS Web serving platform. As with Perl and Python applications, the majority should migrate to Windows/IIS without any modifications.

PHP is available in two different distributions:

  • A ZIP package, which includes support for CGI PHP scripts and server API extensions for the ISAPI system supported by IIS. This package also comes with built-in support for interfacing to the MySQL database and a complete suite of additional extensions.

  • An installer package, which includes support for CGI based PHP scripts and MySQL. Support for ISAPI is not included, and neither are additional external extensions. However, the installation is much more straightforward.


I recommend the ZIP because you get the ISAPI extension, although the installation is slightly more complex.

To install from the ZIP package, follow these basic steps:

  1. Extract the ZIP package using WinZip or the built-in Zip extraction tool.

  2. Copy the directory extracted to a suitable location. The recommended location is C:\PHP.

  3. Follow the instructions in the install.txt document that comes with the package. Be careful because some of the steps require you to edit the registry directly.


Dynamic sites often take advantage of some sort of database, and the most popular solution outside of the commercial solutions, such as DB2 or Oracle, is MySQL. MySQL is also available for Windows and can be used in combination with Perl, Python, and other scripting languages and even ASP/ASP.NET as a SQL solution.

To install MySQL under Windows, follow these steps:

  1. Unpack the MySQL distribution using WinZip or the built-in compressed folders tool.

  2. Change to the MySQL directory, and double-click Setup to start the MySQL installer.

  3. Click Next to continue the installation.

  4. Read the installation notes, and click Next to confirm that you are happy with the default settings.

  5. Check the installation directory. The default location is C:\MySQL. If you change this location, you will need to modify the MySQL configuration file, as mentioned in the previous release notes screen. Click Browse to choose a different install directory. Click Next to continue installation.

  6. Choose the type of installation. The Typical installation includes all the elements that you should need to run MySQL. A Compact installation installs only the minimum amount required to use MySQL. Custom allows you to select which elements to install. Click Next to continue the installation.

  7. If you selected the Custom installation setting, you will be asked to select which elements of MySQL you want to install. Check the items you want to include in your installation. Click Next to continue the installation.

  8. The installation will now start. Once the files have been installed, click Finish to terminate the installer.

You will need to build the initial databases used to hold the grant and security information before you can start using the MySQL database. Follow the instructions given in the MySQL documentation, which you can find in the Docs directory of the installation directory.

graphics/does_icon.gif PERL, PYTHON, MYSQL, AND MORE

Why bother installing these non-Microsoft technologies? They're very popular in Apache installations, and if you're migrating to IIS, things will be much smoother if you don't have to rewrite the Web pages and redesign the database at the same time.


Retooling all of your software for ASP/ASP.NET is not a simple undertaking and shouldn't be considered lightly. Most solutions already mentioned?Perl, Python, and PHP, in particular?should be relatively trouble free and are frequently used as first-time solutions under IIS.


Shellscript is not a standard CGI environment for developing dynamic Web sites, but it is used by some environments either as a CGI scripting language or as a utility language used to batch process logs, requests, or other information for processing elsewhere.

Native support doesn't exist for any of the Unix Shellscript environments within Windows, but some solutions are available. The most obvious of these is Microsoft's own Services for Unix (SFU) and Cygwin, a Unix/Linux like environment for Windows based on the GNU toolset.

SFU provides a combination of support environments for certain Unix stalwarts, shellscripts included, as well as compatibility interfaces and services for Unix hosts, such as NFS client/server support and an NIS-compatible interface to Active Directory. You can use the Shellscript facilities of SFU and Cygwin to execute shellscripts just as you would execute them on a Unix host.

However, neither tool should be seen as a long term solution to the problems of running shellscripts. If you rely heavily on shellscripts for CGI solutions, you should migrate them as quickly as possible. Move them to a cross-platform solution, which will retain compatibility with your Unix installation, especially useful during a migration. Alternatively, if you do not need to retain compatibility, instead migrate them to ASP/ASP.NET.

If they are utility scripts, move them to batch files if you can?the closest Windows equivalent to Shellscript?or, better still, move them to Visual Basic.


Java code should run fine under Windows without modification. If you are using Java Server Pages (JSP) or servlets, you will need to install a JSP/Servlet runner application. The most obvious of these should actually be familiar to you if you use Apache under Unix. It's Tomcat, another of the Apache Software Foundation's projects.

In many ways, getting Tomcat working under IIS is no different than getting Tomcat working under Unix. Installation requires a few careful steps:

  1. Download and install the Sun Win32 Java Development Kit (JDK); you can download it from http://java.sun.com. Using version 1.4.1, this should install Java in to C:\j2sdk1.4.1_01 by default.

  2. Download and install the Tomcat installer package (from http://jakarta.apache.org). When asked to select installation options, make sure that you check the NT Service box. Make a note of the installation directory?with Tomcat 4.1.x, it should be something like C:\Program Files\Apache Group\Tomcat 4.1.

  3. Right click My Computer, Properties, choose the Advanced panel, and then click Environmental Variables. Set TOMCAT_HOME to the location of the Tomcat installation directory and JAVA_HOME to the location of the JDK. Modify PATH so that the first entry is the bin directory within the JDK installation directory.

If you now open a browser to your server on port 8080?that is, http://localhost:8080/ from the server itself?you should get the Tomcat default homepage.


There are ways in which you can connect Tomcat and IIS through an ISAPI redirector, but support for this under IIS 6 is uncertain at the time of writing. Check the Jakarta Tomcat project homepage (http://Jakarta.apache.org) for the most up-to-date information.

Compiled Code

All compiled code?irrespective of the source language?will need to be recompiled under Windows. Visual Studio.NET incorporates a C/C++ compiler if you need one and also provides a rich environment for developing Windows and .NET specific applications and tools.

If you are using compiled applications, you might want to consider retooling the project with ASP/ASP.NET.