Running Windows Web Applications on Linuxand Linux Web Applications on Windows

Running Windows Web Applications on Linux and Linux Web Applications on Windows

So far we've examined issues that apply to static content, such as web pages, images, and other content not generated on-the-fly in response to particular conditions or user-submitted forms. Web servers can also generate web pages and other media types dynamically. For instance, a web page can be generated by fetching information from a database in response to search terms entered by a user .

Both operating systems have "native" ways to do this. Microsoft Windows users running Internet Information Server (IIS) can use Active Server Pages (ASP), a reasonably beginner-friendly system built on Microsoft's Visual Basic language. Microsoft's newest version of ASP, ASP.NET, allows many programming languages to be used, notably Microsoft's C# language. That's possible because ASP.NET leverages .NET's Common Language Interface (CLI), which we'll discuss in a bit more detail later. Of course, programmers can still use VB.NET, the latest version of the Visual Basic language that ASP programmers have traditionally used most often.

Although a wide range of programming languages can be used to extend Apache-based websites , including Perl, Python and Ruby, most Apache webmasters use PHP. PHP is quite friendly to beginning web developers. While past versions of PHP were lax about security issues, modern versions are as safe to use as other web programming languages.

Both PHP and ASP were originally intended for those who have mastered static web pages and need to sprinkle in a little bit of server-side programming rather than use scripts that run at the client. Both languages have a syntax that makes it convenient to include short snippets of code in a web page.

Today, however, both ASP.NET and PHP have evolved into mature systems that can be used to develop large web applications any webmaster might want to reuse applications that, quite often, are open source. And that's great. But what if you're an IIS webmaster and the web application you want to use runs on PHP? For that matter, what if you're running Apache and you want to run an ASP application? We'll address both of these scenarios in the remainder of this chapter.

Note 

There is an important "third way" here: Sun's Java 2 Enterprise Edition (J2EE). J2EE offers the ability to create Java-language web applications called "servlets" that can accomplish goals similar to those of PHP and ASP.NET. We don't go into depth about J2EE in this chapter precisely because it is already well supported on both Windows and Linux. As a result, there aren't a lot of interoperability concerns there, and you won't need a lot of help from us to get started. We've chosen to focus on the more challenging tasks of making .NET work with Linux and making PHP work with Windows. But J2EE is certainly a viable option you should check out if you have the luxury of choosing your own web development environment. You can learn more about J2EE on Sun's website, at http://java.sun.com/j2ee/index.jsp .

Running Linux PHP Applications on Windows IIS Servers

For Windows webmasters who want to run PHP applications, there's great news: full-blown PHP can be used with IIS for free! And so can the MySQL database engine that many worthwhile PHP applications depend upon. In fact, using the database instead of files to store information tends to make web applications more portable between Linux and Windows because Structured Query Language (SQL) is an open standard and MySQL behaves the same on both operating systems. In this chapter, we'll examine how to integrate PHP and MySQL with IIS and show how to run the popular PHP-based phpBB web-based bulletin board application on an IIS server.

Note 

Windows users can also choose to run the Apache web server on Windows in place of IIS. Apache for Windows has matured considerably in recent years , but the Apache website specifically warns that Apache for Windows has not yet been optimized for performance. By contrast, IIS 6.0 is tightly integrated with the Windows operating system kernel. You can learn more about Apache for Windows at the Apache Foundation website: www.apache.org .

So, PHP applications can run on IIS? Great! How do we get started? Actually, before we get started, it might be good for us to determine which PHP application we ultimately want to run on Windows IIS. If you check out www.winlinanswers.com and click on the Community Forum, you'll see that we're running a forum called phpBBa simple bulletin board with a lot of power. Yes, on our particular real-world website, we're running it on a Linux server. But the point is that this is a cool piece of free software that we love and use for production work. And you might fall in love with it too. To that end, we'll show you how to set it up to run on a Windows IIS server if you so choose.

Warning 

One word of warning about open-source web applications: keep them up-to-date or you risk security breaches! The good thing about open source is that security holes are quickly found and quickly fixed. But if you don't install the fixes, this doesn't help you. If you choose to install phpBB or a similar program, particularly in an Internet environment, you'll need to watch the home page of the software closely for announced updates and be sure to install any security fixes.

Installing the MySQL Database Engine and Creating a Database for phpBB

We'll begin by installing the free, open-source MySQL database engine on exchange2003.ad.corp.com , a server on which we already installed IIS in Chapter 6 in order to provide a web browser interface to the Exchange mail server. If you didn't install IIS on exchange2003.ad.corp.com in Chapter 6, you'll need to do so before proceeding.

Once we've installed MySQL, we'll use the MySQL command line client to create a database where phpBB can store forum posts, forum users, and the rest of its data.

Warning 

For test lab purposes, there's no harm in running other web applications on our Exchange 2003 server. But in a production environment, this is not a good choice. All web applications such as phpBB expose the system to some risk because new security flaws are occasionally discovered and exploited in such applications. Responsible webmasters should minimize that risk by separating the general-purpose web server from the Exchange 2003 server.

Downloading and Installing MySQL

We'll start by downloading the latest stable version of MySQL for Windows, currently MySQL 4.1.12a. Follow these steps on exchange2003.ad.corp.com to download the latest stable version of MySQL for Windows:

  1. Visit the MySQL home page, at: http://dev.mysql.com

  2. Click "Downloads" to reach the "MySQL Downloads" page.

  3. Scroll down to "MySQL 4.1" or whichever release is currently labeled as the "Generally Available (GA) Release (recommended)" and click the "MySQL 4.1" link. The "MySQL 4.1 Downloads" page will appear.

  4. Scroll down to "Windows downloads" and locate the "Windows (x86)" package. Click "Pick a mirror" to begin the download process. A user information form appears.

  5. Complete the user information form or, alternatively, click "No thanks, just take me to the downloads!"

  6. Pick the mirror site closest to you. A ZIP file will begin to download. When prompted, save the ZIP file to the desktop.

We've downloaded the setup program, in the form of a ZIP archive. Now we're ready to unzip and install MySQL. The installation program has many screens, but we'll accept the defaults for most of these. For space reasons we won't mention defaults that are not relevant for our purposes.

The installation program is actually two programs: a setup wizard and a configuration wizard. The configuration wizard prompts for one noteworthy piece of information, a root password . The MySQL root password is not intended to be the same thing as your Windows administrator password. In a production environment, you should never use the Administrator password for the MySQL root password.

The MySQL root password is used only by programs and scripts that need permission to create and delete databases. Such programs can also create less privileged MySQL accounts that have access only to certain databases and cannot create new databases. For test lab purposes, we'll use the password p@ssw0rd , but you should choose a secure password in a production environment.

Follow these steps on exchange2003.ad.corp.com to unpack, install, and configure MySQL for Windows:

  1. On the desktop, double-click the ZIP file we downloaded in the previous set of steps. The Setup.exe program will appear as the sole file inside the ZIP archive.

  2. Double-click Setup.exe to launch the installer.

  3. The "Welcome to the Setup Wizard for MySQL Server 4.1" screen appears. Click " Next " to proceed.

  4. The "Setup Type" screen appears. Choose "Complete" for a complete installation and click "Next" to continue.

  5. The "Ready to Install the Program" screen appears with a brief review of what will be done. Click "Install" to begin the actual installation.

  6. The "MySQL.com Sign-Up" screen appears. Sign up for an account, or just select "Skip Sign-Up." Then click "Next."

  7. The "Wizard Completed" screen appears, with a check box labeled "Configure the MySQL Server Now." Be sure this box is checked and click "Finish."

  8. The "Welcome to the MySQL Server Instance Configuration Wizard" screen appears. Click "Next."

  9. The "MySQL Server Instance Configuration" screen is displayed. Select "Standard Configuration" and click "Next."

  10. The "Please set the Windows options" screen is shown. Make sure "Install As Windows Service" is checked, and click "Next."

  11. The "Modify Security Settings" screen appears. The "Modify Security Settings" box should be checked. Enter p@ssw0rd in the root password field and click "Next."

  12. The "Ready to Execute" screen is shown. Click "Execute" to complete the configuration of the MySQL server.

  13. Click "Finish" to close the wizard.

MySQL is successfully installed on exchange2003.ad.corp.com. But we need to take care of a little snag. MySQL offers a Dynamic Link Library (DLL) that other applications, like PHP, can use to communicate with it. But this DLL is not automatically installed where PHP expects to find it. We will correct this by copying this DLL, libmysql.dll , from MySQL's library directory to C:\WINDOWS\SYSTEM32 where all applications can find it.

To install libmysql.dll for PHP's benefit, follow these steps:

  1. Using the Windows file manager, locate the file libmysql.dll in the folder C:\Program Files\MySQL\MySQL Server 4.1\lib\opt .

  2. Copy this file to the folder C:\WINDOWS\SYSTEM32 .

Initial MySQL Setup

Now we'll verify that MySQL is working properly. And we'll also take care of a necessary step toward running phpBB. We'll accomplish both by creating a database in which phpBB will be able to store information. We can accomplish these things using the simple command line client provided with MySQL.

A command-line utility is friendlier to typical MySQL users than it may sound because MySQL's administrative commands are just an extension of the familiar Structured Query Language (SQL) with which database-savvy web developers are often familiar. But don't worry, we don't need to master SQL to execute a few simple commands that create a database, create a new MySQL user called phpbb with the usual test lab password ( p@ssw0rd ), and grant that user the privilege of working with the database we've created.

To do these things, we'll use the create database command to make a database and use the grant all privileges command to offer control of that database to a specific user. The grant all privileges command creates the user for us along the way.

In addition, we'll use the set password command to adjust the password for compatibility with PHP. MySQL 4.1, by default, uses a new password authentication protocol that requires changes to client applications. PHP's standard MySQL support functions, even in the most current 5. x versions (we'll stick with the 4.3. x series in this book because it installs much more smoothly on Windows as of this writing), do not understand this protocol. An alternative MySQL extension for PHP 5. x does exist, but existing PHP applications may not know how to use it and it isn't currently included in Windows distributions of PHP. Ugh! Fortunately, we can work around this by telling MySQL to use an "old-style" password for the phpbb account. Since the only database connections we allow are from localhost (the web and database server itself), there is no possibility that these passwords will be "sniffed" on the wire.

To create a database and a MySQL user account for phpBB on exchange2003.ad.corp.com , follow these steps:

  1. Launch the command line client with this sequence of menu choices:

    Start image from book All Programs image from book MySQL image from book MySQL Server 4.1 image from book MySQL Command Line Client

  2. An "Enter password:" prompt appears. Enter the MySQL root password, which we have set to p@ssw0rd in our test lab. The mysql> prompt appears.

  3. At the mysql> prompt, key in the following MySQL command to create a database for phpBB's benefit:

     create database PHPBB; 

    You will receive a response similar to the following:

     Query OK, 1 row affected (0.02 sec) 
  4. Key in the following MySQL command to grant control of the new database to the user phpbb:

     grant all privileges on PHPBB.* to phpbb@localhost identified by 'p@ssw0rd'; 

    This will produce a response similar to the following:

     Query OK, 0 rows affected (0.02 sec) 

    "0 rows affected" is not an error. Privileges have been set correctly.

  5. Adjust the password for compatibility with the older MySQL client libraries used by PHP:

     set password for phpbb@localhost = OLD_PASSWORD('p@ssw0rd'); 

    This should produce a response similar to the following:

     Query OK, 0 rows affected (0.02 sec) 

    "0 rows affected" is not an error. The password has been adjusted correctly.

  6. Exit the client by typing the quit command and pressing Enter.

Installing and Testing PHP for Windows

We've verified that the MySQL database engine works properly. And we've created the database we'll use for phpBB. Now we're ready to install PHP for Windows itself, bringing PHP programming capabilities to our IIS web server. We'll install PHP and perform a simple test of its integration with IIS before demonstrating the big payoff by installing the phpBB forum software.

For the most part, installation is straightforward. Again, there are many prompts but for the most part we can accept the defaults. There is one catch. The PHP installation program uses scripts written in Microsoft's VBScript language to accomplish some of its tasks. And on our Windows 2003 / SP 1 server, we found that these scripts generated warning dialogs indicating that they could not be run by wscript , one of Microsoft's script interpreters. Fortunately, Windows offers up the alternative of running the scripts under Microsoft's cscript interpreter instead. The prompts are a bit cryptic, so we've spelled out the right steps for you.

One more issue: the current "stable" version of PHP is the 5.0 series. But we've found that integrating this version with MySQL on the Windows platform is quite difficult. So, like quite a few PHP users at this point, we're sticking with the PHP 4.3 series until things are a little more settled.

Installation of PHP 4.3 for Windows

Follow these steps to install PHP support on exchange2003.ad.corp.com :

  1. Visit the PHP home page at www.php.net .

  2. Click "downloads" to reach the "PHP: Downloads" page.

  3. Scroll down to "Windows Binaries."

  4. Scroll down farther and click "PHP 4.3.11 installer" (the version number you see may be newer ).

  5. A list of mirror sites appears. Select the mirror site closest to you.

  6. Save the php-4.3.11-installer.exe file to the desktop.

  7. Double-click the installation program on the desktop.

  8. The "Welcome to PHP 4.3.11 Setup program" screen appears. Click "Next."

  9. The PHP license terms appear. Review them before clicking "I Agree." The PHP license permits you to take full advantage of PHP in a for-profit fashion.

  10. The "Installation Type" screen appears. Make sure "Standard" is selected and click "Next."

  11. The "Choose Destination Location" screen appears. We recommend accepting the default location by clicking "Next."

  12. The "Mail Configuration" screen appears. This screen only affects PHP scripts that send e-mail. In the "SMTP server" field, localhost is the default, which is correct because exchange2003.ad.corp.com is a mail server. In the "'from' address" field, enter root@corp.com . Then click "Next" to continue.

  13. The "Server Type" screen appears. Here we indicate what type of web server we want to install PHP support for. By default, "Microsoft IIS 4 or higher" is selected. Change this to "Microsoft IIS 6 or higher" and click "Next."

  14. The "Start Installation" screen appears. Click "Next" to perform the actual installation.

  15. An "IIS has been configured" message box will appear, informing you that IIS has been configured to recognize PHP scripts. Actually, this is not quite true yet, as we'll see in a moment. Click the "OK" button to continue.

  16. A "Windows Script Host" message box appears with the message "This script does not work with WScript." Click "OK" to continue.

  17. A "Register CScript" message box appears with the message "Would you like to register CScript as your default host for VBScript?" Click "Yes." Otherwise PHP will not be correctly integrated with IIS.

  18. A confirmation prompt appears indicating that CScript has been successfully registered. Just click "OK."

  19. The "Installation complete" message box appears with additional information about user permissions that did not require modification in our tests. Click "OK."

PHP is installed and configured, with all the little details right for our needs. But how can we be sure it's working?

Testing PHP for Windows

We'll find out by creating a trivial PHP page, in the home directory of our IIS server. We'll spice up that page by including a simple command that prints out a fancy and highly readable listing of the PHP features that are enabled so that we can verify that MySQL support is available. Then we'll access that page with a web browser. If we see the output correctly, PHP is working. If we see an empty page, it's not.

Although this is not a programming book, it's handy to have some understanding of what we're looking at. PHP code, like that of other embedded web development languages, is typically inserted into HTML pages. PHP has a standard syntax for this, using <?php to begin a block of PHP code and ?> to end it. Anything between those markers is interpreted by the PHP engine. The rest of the page is sent unmodified to the web browser as one would normally expect.

In our test PHP code, we'll use PHP's echo command, which outputs a quoted string of text to the web browser. By placing the actual body of the page here, we'll find out whether PHP is working. If PHP isn't working, we'll see an error message, or an empty page. If PHP is working, we'll see "PHP Test Page" in a large font, as shown in Figure 10.2.

image from book
Figure 10.2: The MySQL- related portion of the output shown in our PHP test page when PHP and MySQL support are correctly configured on exchange2003.ad.corp.com

We'll also use a second echo command, which will display the output of PHP's phpinfo() function. phpinfo() returns a rather nice HTML table that shows which PHP features are installed and available. We should see MySQL support listed in this table.

The home directory of our IIS server, if you didn't choose to change the default when configuring IIS, is C:\inetpub\ wwwroot . This is the folder IIS looks in to find content when a web browser makes a request to access a file.

Follow these steps to create and test a simple PHP page on exchange2003.ad.corp.com :

  1. Using Notepad, create the file C:\inetpub\wwwroot\test.php

  2. Insert the following HTML with embedded PHP code:

     <html> <head> <title>PHP Test Page</title> </head> <body> <?php   echo '<h1>PHP Test Page</h1>';   echo phpinfo(); ?> </body> </html> 
  3. Pull down the File menu and choose "Save As."

  4. On the "Save as type:" pull-down menu, be sure to select "All Files." Otherwise an unwanted .txt extension will be attached onto the end of the filename.

  5. In the "File name :" field, enter test.php .

  6. Click the "Save" button.

  7. With your web browser, access the URL http://exchange2003.ad.corp.com/test.php

When you complete these steps, you should see "PHP Test Page" in a large font followed by a listing of PHP features. Scroll down or search the page for "mysql" and you'll find the information shown in Figure 10.2. If instead you see "File not found" or a similar error, or you see a blank page, double-check that you created the test.php file and placed it in the proper directory. If so, we recommend running the PHP installation program again. Most likely the VBScript code used by the PHP installer did not work on the first try, probably because you did not answer "Yes" to registering CScript as the default VBScript interpreter. (Yes, this is a pain, and hopefully the next update of the Windows PHP installer will make this annoyance go away!)

If the page does appear otherwise correct but doesn't mention MySQL support, make sure that you have installed the PECL extension DLLs, enabled them in php.ini , and copied libmysql.dll to C:\Windows\System as described earlier.

Installing and Testing the phpBB Forum Software on Windows

Now that we've created a complete, database-capable PHP environment for our IIS server and created a database for phpBB specifically, we're ready to install phpBB. phpBB provides bulletin boards , or forums, with an impressive set of features for users and administrators alike. PHP's ease of use has led to an explosion of such simple and popular open-source software. Now you can leverage these tools under Windows.

Note 

Unlike some popular PHP applications, phpBB is actually rather Windows friendly and can be used with Microsoft SQL Server or even Microsoft Access ODBC instead of MySQL. However, we're using MySQL because it is a popular component of many open-source PHP web applications you may wish to run on your Windows server, not all of which can be used without modification with other database softwareand, of course, because it's free and works really well.

Downloading and Unpacking phpBB

Before we can install the software, we need to get hold of it! Follow these steps to download and unpack the phpBB software on exchange2003.ad.corp.com :

  1. Visit the phpBB home page at www.phpbb.com .

  2. Click the "Downloads" button to access the downloads page.

  3. Locate the current full package download, currently labeled "phpBB 2.0.16 [ Full Package ]." Click on the ZIP icon to the right.

  4. Save the ZIP file to the desktop.

  5. Right-click the ZIP file on the desktop and select "Extract All."

  6. The "Welcome to the Compressed ( zipped ) Folders Extraction Wizard" screen appears. Click "Next" to continue.

  7. The "Select Destination" screen appears. Change the "Files will be extracted to this Directory:" field to C:\Inetpub\wwwroot . Click "Next" to continue.

  8. The "Extraction Complete" screen appears. Leave the "Show extracted files" box checked, and click "Finish."

The contents of the C:\Inetpub\wwwroot\phpBB2 folder are now displayed in a Windows Explorer window. This folder is within the home directory of our web server, so it can be accessed with a web browser. Notice the install subfolder. This folder contains scripts that should be used only once to install phpBB. Once we're done with them, we'll remove this subfolder entirely.

Configuring phpBB

To begin configuring phpBB, we'll access the built-in, PHP-based installation scripts using a web browser. We need to do this promptly because until we do so, the newly installed software is exposed to the possibility that someone else will configure it first.

On phpBB's built-in configuration page, we'll make choices in three categories: general settings, database-related settings, and information about the phpBB administrative user. For space reasons, we won't mention options for which the defaults are acceptable and whose significance is outside the scope of this chapter.

To configure phpBB, follow these steps on exchange2003.ad.corp.com :

  1. Access the following URL using Internet Explorer running on exchange2003.ad.corp.com itself. This will simplify later tasks:

    • http://exchange2003.ad.corp.com/phpBB/install/install.php

  2. The "Welcome to phpBB 2 Installation" page will appear.

  3. Set "Database type:" to MySQL 4.x.

  4. Leave "Choose your installation method:" set to "Install."

  5. In the "Database server hostname:" field, accept the default setting of localhost . (This is correct because the MySQL server is running on the same computer as phpBB.)

  6. Set the "Your Database Name:" field to PHPBB .

  7. Set the "Database Username:" field to phpbb .

  8. Set the "Database Password:" field to p@ssw0rd .

  9. Set the "Admin Email Address:" field to root@corp.com or the address where you would prefer to have administrative notices from the software delivered.

  10. The automatically detected setting for "Domain Name," exchange2003.ad.corp.com , is correct. What is meant here is the full hostname of the website. "Fully Qualified Domain Name" would have been less confusing.

  11. Set the "Administrator Username:" field to admin .

  12. Set both "Administrator Password:" fields to p@ssw0rd .

  13. Click "Start Install" to carry out the configuration of phpBB.

Some time should pass before you see the page shown in Figure 10.3.

image from book
Figure 10.3: Because IIS has tight security policies, phpBB can't write to its configuration file directly.

This page indicates that installation is going well but phpBB can't write directly to its configuration file. This is normal under IIS, which has tight security policies by default. Since, with the exception of a few global configuration settings, phpBB keeps all of its data in a MYSQL database, we won't tell IIS to lower the protections . Instead, we'll take advantage of the second option shown in Figure 10.3, downloading the configuration file and then copying it into place ourselves . (We won't actually use FTP. If you are running your browser on the server itself, you can simply copy the file to its final destination.)

Follow these steps to install the configuration file for phpBB:

  1. Select the "Just send the file to me and I'll FTP it manually" option.

  2. Click "Download Config."

  3. Click "Save."

  4. Save the file to the following folder:

     C:\inetpub\wwwroot\phpBB2 

This overwrites the existing (but empty) file config.php .

Basic installation is almost complete! However, if you try to access phpBB2 now at the following URL, you'll receive the error "You are not authorized to view this page":

  • http://exchange2003.ad.corp.com/phpBB2/

That's because IIS is not configured to recognize index.php as a valid name for a directory home page, but most PHP applications assume that it will be treated as such. And IIS is configured to refuse to display a list of files present in a folder as an alternative when no directory home page exists. So we're out of luck unless we add index.php to the end of the URL or are we?

As it turns out, we can fix the problem using the "Internet Information Services (IIS) Manager" application of Windows. Follow these steps to make index.php a valid name for a folder home page, or "default content page" in IIS terminology:

  1. Choose Start image from book Administrative Tools image from book Internet Information Services (IIS) Manager.

  2. The "Internet Information Services (IIS) Manager" window appears. In the left-hand pane, click "Exchange 2003 (local computer)." The right-hand pane will update to reflect aspects of this computer's web servers.

  3. In the right-hand frame, double-click "Web Sites." A list of websites appears, containing only "Default Web Site."

  4. Right-click "Default Web Site" and select "Properties." The "Default Web Site Properties" window appears.

  5. Click the "Documents" tab.

  6. Beneath "Enable default content page," which should be checked, click the "Add" button. The "Add Content Page" dialog appears.

  7. Enter index.php and click "OK." index.php is added to the list of content page filenames.

Now we can access phpBB2 at the following URL:

  • http://exchange2003.ad.corp.com/phpBB2/

When we do, though, we'll see one last issue: a message reminding us to delete the install and contrib folders from the phpBB2 folder. These folders contain the installation pages we just used and contributed code that we don't need. Both are dangerous to leave lying around because a rogue user could use these pages to reconfigure phpBB2.

Fix the problem by following these steps on exchange2003.ad.corp.com:

  1. Delete the folder C:\inetpub\wwwroot\phpBB2\install .

  2. Delete the folder C:\inetpub\wwwroot\phpBB2\contrib .

We're finally ready to go! Access phpBB one last time:

  • http://exchange2003.ad.corp.com/phpBB2/

You'll see the phpBB welcome page as shown in Figure 10.4. Log on as the phpBB administrative user (username admin , password p@ssw0rd ) to explore the capabilities of phpBB.

image from book
Figure 10.4: The welcome page of phpBB, open-source PHP-based forum software running successfully under PHP for Windows on Internet Information Server

At this point, we'll stop and let you explore your phpBB universe if you like. We've achieved our goal. Again, if you're interested in actually configuring phpBB for your use in-house (or to put on the Web), be sure to check out www.phpbb.com .

Running Windows ASP and ASP.NET Web Applications on Linux Servers

PHP and its relatives are compelling choices for web design because of their simplicity, friendliness, and low cost. But the modern Windows platform has its own impressive option to offer: the .NET architecture. .NET (which is not an acronym) allows programmers and web designers to create code in a variety of modern programming languages and run that code in an environment in which many important tasks are taken care of automatically for the programmer.

In the past, web applications on IIS servers were often based on an older Microsoft technology, Active Server Pages (ASP). At first, these applications were nearly always written in Visual Basic, a language with its own following but not popular among those more accustomed to C, Java, Perl or C++. But today ASP.NET, the modern successor to ASP, allows any programming language supported by .NET to be used. This has far-reaching implications.

For instance, ASP.NET provides a good implementation of "user sessions," keeping track of individual users as they move through the website and providing the ability to easily program an ongoing interaction with each individual user. Visual Basic programmers always had access to this through ASP. Today, however, programmers can also use Microsoft's C# language, along with a very large number of other languages. The list includes Java (Microsoft's J#, which is compatible), JavaScript (Microsoft's JScript.NET, which is compatible), and C++ (when used with Microsoft's Extensions for C++, commonly referred to as Managed C++), along with many lesser-known languages. Even Python and Perl can be used, although the .NET versions of Python and Perl available at this time from www. activestate .com are still experimental. This is possible thanks to .NET's Common Language Interface (CLI), a published standard that allows anyone to add .NET support for an additional programming language.

But this isn't a programming book, so why are we talking about these issues here? Since ASP.NET and legacy ASP offer strong features for web development, many companies use them as part of their intranet and Internet websites. Web designers in an otherwise Linux-friendly company might not be familiar with PHP and other typically Linux-hosted options for server-side web programming. And existing third-party .NET and ASP applications may also be in use or of potential interest. As with the Samba-based Active Directory domain member file server we built in Chapter 4, the ability to do these things on the Linux platform can save wear and tear on a more expensive Windows server or remove a barrier to using Linux for a particular department's needs. Your web developers may know ASP, but they probably don't know system administration. That's where you can help them by providing an ASP environment on a Linux-based server.

But can Linux do it? That depends on your specific needs. The good news is that an opensource implementation of .NET called Mono (also not an acronym) has emerged for Linux and other non-Windows operating systems. The bad news is that, as of this writing, Mono doesn't implement everything that Microsoft's .NET environment provides. But if your needs are a good fit for what Mono does provide, you're in good shape. And important new features of Mono are close to release. Those features fill significant gaps in what Mono can do for us today. We'll highlight these features when we examine Mono more closely in this chapter.

Mono has one major weakness, as of this writing, from the perspective of Windows web developers. That weakness is the lack of a complete VB.NET compiler. That means that Mono is not currently a complete solution for those who want to write or maintain Active Server Pages containing code written in the Visual Basic language. Although C# is widely considered to be the best language choice for stand-alone .NET applications, Visual Basic skills are not uncommon among web developers who are used to a Windows environment. And since it was once the only serious option for ASP, Visual Basic is still particularly popular for web development. So this may be an issue for you if you attempt to move content to a Linux-based server using Mono.

You might ask why this matters if VB.NET code can be compiled on a Windows workstation and then run on the Mono platform. The answer is that ASP.NET pages can and do regularly contain VB.NET source code right in the web page, not unlike the way PHP is embedded in web pages. This is a common way to build simple intranet web applications. And it only works when a compiler for VB.NET is available on the web server , where those web pages are. That's why a complete VB.NET compiler for Mono is an important missing feature.

So what can we do if we need support for Active Server Pages written in Visual Basic today? The Mono VB.NET compiler is making rapid progress and should be available as a "technology preview" by the time this book hits the shelves . But there is also an alternative solution, one that is more appropriate for those who must have "traditional" ASP support and the Visual Basic language in its pre-.NET dialect . That solution is Sun's Sun Java System Active Server Pages 4.0. That's quite a mouthful, and a tough acronym to pronounce as well. So we'll refer to it simply as JASP for short.

The good news is that JASP is available now, and it works. The bad news is that JASP is not free. JASP licenses for single websites currently sell for prices in the neighborhood of $495 per server. And that can cast doubt on the business case for hosting ASP content on Linux, although it may be acceptable for web hosting companies who expect to host thousands of websites on a single server. We'll look more closely at JASP later in this chapter.

Running Windows ASP.NET on Linux with Mono

Mono is an open-source implementation of Microsoft's .NET architecture. That's an impressive achievement. How can such a thing exist? Is it a product of reverse engineering like Samba? For the most part, no. Important parts of .NET are published standards that anyone can potentially implement.

To be precise, parts of .NET are covered by Ecma standards #335 and #334. (Ecma International is an association that publishes industry standards.) Of course, Microsoft had sound business reasons for making this decision. Microsoft wants the world to use .NET and C#, as well as other .NET-friendly languages. And Sun's earlier attempt to achieve universal popularity for its Java architecture ran into trouble in part because of Sun's unwillingness to make Java an open standard. However, see the sidebar ".NET, Mono, and Intellectual Property Rights" for patent-related concerns about .NET and Mono.

image from book
.NET, Mono, and Intellectual Property Rights

Microsoft has made aspects of .NET an open standard and given some indication that it will be allowing these aspects to be used by anyone under royalty-free terms. Microsoft deserves credit for that. Before we take the love fest too far, though, it's worth pointing out that Microsoft has been aggressive in filing patents on many aspects of the .NET system. Microsoft has done nothing to suggest that it will aggressively enforce these software patents in the way that Unisys did with the infamous "GIF patent," which actually covered the encryption algorithm used in GIF-format images. But it certainly could, and some feel that is cause for concern. After all, Unisys did not take action until GIF had been in wide use for many years. If Mono "triumphs" and becomes the most popular way of developing software for Linux, Microsoft could choose to exact patent license fees on those who use certain aspects of it.

To be fair, IBM and other companies are also very aggressive in filing patents on their technology, and not all companies choose to enforce their patents on software development ideas. Since the patent office has had difficulties in recent years recognizing what is "prior art" (something that someone else has already done) and what is a new idea, patents are sometimes used defensively to ensure that other parties cannot enforce patents on the same concept. Still, at least one Microsoft patent on .NET does cite specific features by name that are not included in the open standard but are important parts of support for web applications. This could be used to shut down projects that provide free reimplementations of those features. For more information, see Derek Ferguson's March 27, 2003 article in .NET Developer's Journal:

  • http://dotnet.sys-con.com/read/38836.htm ( shortened to http://tinyurl.com/bmson )

image from book
 
To Mono or Not to Mono

The fact that the CLI and C# are open standards greatly simplifies the process of creating an alternative implementation like Mono for the Linux platform. And not surprisingly, CLI and C# are the most mature components of Mono. In addition, Mono contains a fairly mature implementation of ASP.NET, the Active Server Pages engine that allows code to be embedded in web pages Microsoft style. Even better, Mono offers an Apache web server module that allows ASP.NET to be used in web pages served by Apache. As long as those pages contain code written in a language for which Mono offers a reasonably mature and complete compilerand as of this writing, that pretty much means C#you're in good shape.

image from book
MainSoft's Visual MainWin: Leveraging and Giving Back to Mono

MainSoft ( www.mainsoft.com ) is a software company focused on cross-platform software development. It has created a product called Visual MainWin, which heavily leverages the Mono project. And though its end product is not open source, it has contributed a significant amount of code back to the Mono project.

MainSoft's principal offering is Visual MainWin for J2EE, a plug-in for Microsoft's Visual Studio development tool. Wait a minute! What does Java 2.0 Enterprise Edition (J2EE) have to do with .NET? Well, Visual MainWin for J2EE allows .NET applications to be run on the J2EE platform, which is one valid way of achieving cross-platform portability for .NET applications.

How does Mono tie in? MainSoft has its own translator to "recompile" .NET binaries into Java binaries. But since those .NET programs will be expecting the entire .NET library to be out there, ready to use, translating the binaries doesn't solve the whole problem. Running existing .NET applications on J2EE requires that MainSoft essentially implement .NET on top of Java. And starting that project from scratch, when there's a promising open-source implementation of .NET kicking around, would be foolhardy. So Visual MainWin for J2EE relies heavily on Mono to implement the "middle layer" between .NET applications and MainSoft's Java-based "back end." And that provides MainSoft with a king- sized motivation to contribute fixes and improvements back to the Mono project, early and often.

Although the use of Java by Visual MainWin for J2EE does introduce one more layer between Linux itself and .NET, it also opens up options. Because they are actually running on top of Sun's J2EE environment, .NET applications built with Visual MainWin for J2EE can take advantage of existing third-party Java objects, better known as Enterprise JavaBeans (EJBs). Those interested in giving MainSoft's offering a whirl will want to check out Grasshopper, a freely distributed Visual Studio plug-in that demonstrates MainSoft's technology. Grasshopper is MainSoft's friendlier nickname for Visual MainWin for J2EE Developer Edition. Grasshopper provides all the pieces needed to build and run .NET applications on the Linux platform using J2EE and the Apache Tomcat server. See dev.mainsoft.com for more information about the free Grasshopper package. Be aware, how- ever, that the free product's output is only licensed for use in the same small-workgroup environment where the developer is employed. Full commercial licensing of the Visual MainWin for J2EE product currently starts at $5,000 per developer.

image from book
 

It's worth mentioning that, while Mono only provides a mature compiler for one programming language, Mono's .NET environment can run already-compiled .NET code (DLLs and executables) created in other languages. However, most in-house web developers prefer to sprinkle source code into web pages using ASP. And coping with that source code requires a compiler. If the source code isn't in C#, you have a problem.

However, help is on the way. In addition to the forthcoming VB.NET compiler mentioned earlier, the Mono community is also in the process of creating a JScript (JavaScript) compiler. But this project is not mature as of this writing. More information is available at www.mono-project.com/FAQ:_Technical .

So Mono is a potential choice for your company's in-house ASP.NET pages that use the C# language. Great. But what about third-party .NET web applications? ASP.NET web applications don't have to place all of their source code inside web pages. They can, instead, refer to precompiled .NET DLLs. That protects the source code from prying eyes, so many third-party applications are distributed this way. An added bonus: since the code is already compiled into a binary format, it doesn't matter whether the code was written in a language for which Mono offers a compiler.

But can Mono run these applications? Yes and no. Yes, Mono is compatible with existing .NET binaries. But no, they often cannot be used in practice because assumptions made by Windows programmers are not always valid when their application runs in a Linux environment. .NET applications can contain "hard-coded" assumptions that don't hold true on Linux. And that means these applications don't quite work under Mono on Linux yet. But since Mono represents a potentially large market of Linux-based web servers that could run .NET software, and because the changes needed to accommodate Mono just as well as .NET are very minor, it is likely that more and more .NET applications will run well under Mono in the near future. See the sidebar "Why Some .NET Web Applications Have Trouble Running under Mono" for details on the compatibility issues and how they can be addressed when source code is available.

image from book
Why Some .NET Web Applications Have Trouble Running under Mono

There are just a few major "gotchas" that prevent .NET web applications from running under Linux with Mono. Here is a list of the most common:

  • .NET applications may rely on the assumption that directories are separated by the \ character, while on Linux they are separated by / . .NET provides a portable way to construct filenames, but many programmers ignore it.

  • Programmers may rely on the fact that Windows filenames are case-insensitive, resulting in "file not found" errors on a case-sensitive file system like those found in Linux.

  • .NET Dynamic Link Libraries (DLLs) are currently compatible with Mono only if they are not compiled with what Microsoft calls "incremental compilation." And there's no way for us, as the customers, to control what options the third-party software vendor may have chosen to use when compiling software. The good news is that vendors can easily fix this by not using incremental compilation for their final release. Incremental compilation is just a convenience for faster development and doesn't improve the final product in any way.

  • Occasionally, web applications will rely on .NET libraries that are not fully implemented by Mono. In most cases, however, the simpler issues listed previously are all that require attention.

Is there hope that third-party .NET applications will run smoothly on Mono? Yes! Jason Alexander, one the authors of nGallery, a well-regarded .NET application for managing photographs, has offered tips for .NET programmers who wish to create applications that work smoothly with both Mono and Microsoft's .NET implementation:

  • http:// blogs .ngallery.org/jasona/archive/2004/04/27/200.aspx

Although programming itself is beyond the scope of this book, those with a little bit of .NET programming expertise may find these tips useful for adapting third-party .NET applications for which source code is available.

You may ask why we didn't demonstrate nGallery in this book if nGallery was written by a .NET programmer who cares about Mono compatibility. The answer is that nGallery has become part of the larger CommunityServer project, which is unfortunately not yet Mono compatible.

image from book
 
Installing Mono on Linux

But enough limitations, provisos, and quid pro quos! Let's stop talking and start doing. It's time to install Mono on our Fedora Core 3 web server, linserv1.corp.com . And once we've done that, we'll demonstrate how to activate support for Mono in the Apache web server and demonstrate that the Mono project's C# ASP examples work. The resulting environment is a potential place to host your company's own C#-based ASP.NET pages, which could formerly live only in the IIS environment. And in the near future, the availability of a complete VB.NET compiler will make Mono a potential host for Visual Basic ASP.NET pages as well.

RPMs providing Mono for Fedora Core 3 are available from the Mono project. Although there are many RPM files involved, they are conveniently packaged in two ZIP archives, one for Mono in general and the other specifically for web application support. Web application support for Mono comes in the form of a specialized web server, called XSP, and a "shim" that allows Apache to talk to it, known as mod_mono .

Follow these steps to download Mono and the supporting files for web application support to linserv1.corp.com:

  1. Visit the Mono project home page, at www.mono-project.com .

  2. Click "Downloads." The Mono download page appears.

  3. Scroll down to "Linux/x86," look right to locate "Red Hat," and click on "Fedora Core 3 x86." The Mono Fedora Core 3 download page appears.

  4. Beneath "Mono 1.1," click "All of these files in a ZIP file." This will download the file mono-1.1.zip .

  5. Scroll farther down the page to "XSP/mod_mono" and click "All of these files in a ZIP file." This will download the file webserver .zip .

  6. Create the directory /tmp/mono with this command:

     mkdir /tmp/mono 
  7. Change directories there with this command:

     cd /tmp/mono 
  8. Move the files mono-1.1.zip and webserver.zip to /tmp/mono . If you downloaded them to the desktop, drag them to /tmp/mono using the Fedora file manager.

  9. Unpack the RPM files with the following two commands:

     unzip mono-1.1.zip unzip webserver.zip 

We're almost ready to install the RPMs. But there's one catch: The latest versions of mono require a lightweight database engine called sqlite. And sqlite isn't standard in Red Hat's Fedora Core 3 repositories. Fortunately, it is available in the Dag Wieers repository, which we first explored in Chapter 9.

Since we've chosen not to directly integrate the Dag Wieers repository into the up2date package management system, we'll fetch the specific RPM we need from the repository. Follow these steps to download the latest version of sqlite for Fedora Core 3:

  1. Visit the page http://dag.wieers.com/packages/sqlite/ .

  2. Locate and click the download link for Fedora Core 3 (fc3) on the Intel platform (i386).

  3. Move the RPM file you have just downloaded to /tmp/mono where you unzipped the other RPMs.

We've obtained all the RPMs we need! All we have to do now is install them. Use the following command to install the RPMs:

 rpm -i *.rpm 

Mono is now installed on linserv1.corp.com! But we still need to configure the Apache web server (also known as httpd, for Hypertext Transfer Protocol Daemon) to support the use of ASP.NET code in web pages. We'll do that by configuring Apache to load the mod_mono module.

Apache can be configured using Webmin, but Webmin doesn't offer a facility for deciding which modules to load. Webmin does offer a way to edit httpd.conf directly as a text file, but this offers no advantages over a text editor and a real text editor is superior to a web browser. So for this particular task, we'll edit Apache's main configuration file directly.

Apache is controlled by the file /etc/httpd/conf/httpd.conf , or httpd.conf for short. This file contains simple options to control the web browser's behavior in a variety of ways. Sometimes these options are grouped together in containers using an HTML-like syntax, like this:

 <container-name value>   sub-option value </container-name> 

Fortunately we don't need to understand all of the options already present in httpd.conf in order to get the job done. There are just a few that matter for our purposes:

  • LoadModule The LoadModule option is used to load an external module providing support for a feature not already built into Apache. We'll use this option to load mod_mono . This option takes two parameters, the module name (in our case, mono_module ) and the filename in which the module is found ( modules/mod_mono.so ). The module name option is there to distinguish between multiple modules released in a single file, although in practice this is rarely done.

  • Alias By default, Apache serves up only the files beneath a single DocumentRoot folder. The Alias option, similar to virtual directories in IIS, allows web paths beginning with a particular folder name to be mapped to any desired directory on the web server. In this case, we'll map the name /test to the directory /usr/share/doc/xsp/test , which is where the ASP.NET samples for the Mono project are installed.

  • AddMonoApplications As mentioned earlier, Mono web applications actually run in a separate server called XSP. The mod_mono module automatically starts up this server when needed. But since XSP is a separate program, it doesn't automatically know about the alias we just created between /test and /usr/share/doc/xsp/test . So we provide that information again for XSP's benefit using the AddMonoApplications option, which is provided by the mod_mono module and used to pass the information to XSP. In our example, AddMonoApplications takes only two arguments. The first argument is beyond the scope of this discussion and should be set to default . The second should be set to "/test:/usr/share/doc/xsp/test" in order to tell XSP that requests for anything in the /test folder actually refer to content in /usr/share/doc/xsp/test .

  • Location The Location option is a container that will hold additional options referring to a specific subdirectory, /test . The Location option begins with <Location followed by the subdirectory name /test followed by a closing > . This is followed by options that will apply specifically to /test and ended with </Location> .

  • SetHandler By default, Apache would deliver the content in the /test virtual directory according to its usual rules. The ASP.NET pages would be downloaded as ordinary HTML without executing the ASP.NET code. The SetHandler option, which appears here enclosed in the <Location /test> container, specifies the "content handler" that will be responsible for delivering content in /test . In this case, we want to use the mono handler so that the mod_mono module can take over and deliver ASP.NET pages correctly via XSP.

Follow these steps to configure linserv1.corp.com's Apache web server to support ASP.NET pages in a /test virtual directory:

  1. Add the following lines to the end of your /etc/httpd/conf/httpd.conf file:

     LoadModule mono_module modules/mod_mono.so Alias /test "/usr/share/doc/xsp/test" AddMonoApplications default "/test:/usr/share/doc/xsp/test" <Location /test>   SetHandler mono </Location> 
  2. Restart the web server with mono support:

     service httpd restart 

If you receive error messages, make sure you actually installed the Mono RPMs following the steps presented earlier.

Access http://linserv1.corp.com/test/ to see the results. Feel free to click on any of the examples, as shown in Figure 10.5.

image from book
Figure 10.5: Sample C# ASP.NET pages, working successfully under Linux via the Mono project

As we've discussed, mod_mono is a good solution for C#-based ASP.NET pages and .NET web applications for which you have the source code, which is typically the case when you are providing an environment for your own company's web developers. But as we've mentioned, support for commercial, closed-source .NET applications is not as thorough, and applications themselves often contain unportable assumptions that can't be fixed in a precompiled program. Since Mono represents a new market for the vendors of such applications, support is likely to improve.

Right now, Mono isn't a mature solution for Active Server Pages written in Visual Basic or JScript. And older ASP applications predating the ASP.NET era may never run unmodified on Mono.

Running Visual Basic Active Server Pages and Applications on Linux with JASP

There is a way to run older ASP applications on Linux. Sun Microsystems's Sun Java System Active Server Pages 4.0, which we refer to in this chapter as JASP for brevity's sake, allows many ASP applications to run unmodified on Linux provided that they don't rely on external components that are not included with JASP.

The bad news is that JASP carries a hefty $495 price tag, and Fedora Core 3 is not a supported platform. However, the closely related Red Hat Enterprise Linux distribution is supported.

Of course, that doesn't mean we can't make it run on Fedora Core 3!

Installing JASP for Fedora Core 3

We've found that JASP does run under Fedora Core 3 with a little bit of effort. And we'll demonstrate that here. However, since using an unsupported operating system could limit your access to the support you deserve on this $495 product, you might consider adding the cost of Red Hat Enterprise 3.0 to that price tag when you do your calculations.

Follow these steps to download and unpack a free evaluation copy of JASP on the linserv1.corp.com web server:

  1. Access the JASP home page at www.sun.com/software/chilisoft/index.xml .

  2. Follow the download link for the latest version currently available, which as of this writing is version 4.02.

  3. Download the Red Hat Enterprise Linux 3.0 version and move the resulting TAR file to /tmp on linserv1.corp.com.

  4. Create a subdirectory to contain the unpacked files with this command:

     mkdir sjsasp402-linux 
  5. Change to that directory:

     cd sjsasp402-linux 
  6. Unpack the TAR file in the parent directory:

     tar -xf ../sjsasp402-linux.tar 
  7. Use the ls command to display a list of the files in the package, including install.sh , the installation script:

     ls 

You could attempt to run install.sh now. If you did, though, you'd receive an error indicating that JASP requires the libstdclibc6.1-1.so.2 library, which is not installed. In fact, Fedora Core 3 includes a newer version of this package that is not backward compatible with applications already precompiled for older versions. And most packages in Red Hat Enterprise Linux 3.0 are older than the cutting-edge software included in Fedora Core 3.

So what to do? Is there an easy way to find the right command to install this missing file? We've already met the up2date package manager. But while up2date is useful, it doesn't provide an easy way to answer the question, If I need this specific version of a library, what command will install it for me?

We'll take advantage of an alternative Fedora package manager, yum , to answer that question. The yum package manager offers a provides option that can be used to locate the name of the package that contains a needed file.

yum provides will output the name of the package, separated by a space from additional information about the package that is beyond the scope of this discussion.

Follow these steps to identify and install the package we need:

  1. Use the yum provides command to identify the package we want. yum provides will take a long time to complete:

     yum provides libstdc++-libc6.1-1.so.2 
  2. Examine the output to determine the package required. The output should resemble this:

     compat-libstdc++.i386 8-3.3.4.2 base 
  3. Use the up2date command to install that package. We can leave off the .i386 part, which is assumed since this is an Intel-based system:

     up2date compat-libstdc++ 

Once the compat-libstdc++ package has been successfully installed, we're ready to run the JASP installer. This is a text-based but reasonably friendly installation program.

Follow these steps to install JASP:

  1. Start the installation script:

     ./install.sh 
  2. Page through the license agreement with the spacebar.

  3. Type yes to accept the agreement and press Enter.

  4. You'll be asked where you wish to install the software. The default suggestion, /opt/casp , is a reasonable place. Press Enter to accept it.

  5. The locale menu appears next, asking which national language and character set should be default. Select your preference and press Enter. We chose English (United States) by entering the number 1 and pressing Enter.

  6. You'll be asked how JASP should go about locating Apache's configuration files in order to configure them. JASP can search your hard drive exhaustively for all possible Apache installation locations, but the default "moderate" option (option 2) works just fine for a standard installation of the Apache httpd package on Fedora Core 3. Type 2 and press Enter.

  7. The "Web Server Configuration" prompt follows . Select option 1 and press Enter to install JASP on the detected Apache server. If you see no such option, make sure you installed the httpd package and install it if necessary with the up2date httpd command; then run install.sh again.

  8. Next is the "Web Server Verification" prompt. Enter y and press Enter to accept the detected information.

  9. An additional "Server Configuration" prompt appears. Select 1 and press Enter to perform a standard installation of JASP. There will be a delay while the installation takes place.

  10. The "Administration Console Installation" prompt follows. The default option, option 1, will install a built-in administration console with a default administrative username and password. For test lab purposes, that's just fine. Enter 1 and press Enter.

  11. The "Administrative Console Information" prompt appears. This prompt presents information about how to log into the administrative console of JASP, which you'll want to write down. During our installation, the reported information was as follows:

     To connect from a browser, use this URL: http://linserv1.corp.com:5100 To start, stop and add users, use this script: /opt/casp/admtool The console's username is: admin The console's password is: root 
  12. Press Enter to move on to the "Product Verification" display, where the installation's success is verified. This takes a few minutes, after which the installation is complete.

JASP has been installed and is now integrated into Apache. From now on, all Active Server Pages found on the website will be recognized by their .asp extension and processed by the JASP engine.

Testing a Sample ASP Application with JASP

But does it work? Let's find out by creating a simple "Hello World" ASP page. Although this is not a programming book, a quick explanation of what we're looking at will still be helpful.

JASP, like Microsoft's pre-.NET ASP system, recognizes ASP code in an HTML page by looking for it between the markers <% and %> . One of ASP's most important capabilities is the ability to generate parts of the HTML page currently being sent to the user. This is what allows parts of the page to contain dynamically retrieved information, such as the results of a database query.

When we place the code

 response.write("<h1>JASP Test Page</h1>") 

between <% and %> and give the page a filename ending in .asp , the JASP engine will recognize that code and execute it every time a web browser accesses the page, and the HTML between the quotes will be sent to the browser as part of the page. The web browser never sees the code. The browser sees only the HTML that the code generates.

Since part of the HTML code for the page is generated by ASP code, the page will appear empty in a web browser unless the JASP engine is working. Follow these steps to create and view a test ASP page:

  1. With your preferred text editor, create the file /var/www/html/test.asp on linserv1.corp.com.

  2. Place the following content in the file:

     <html> <head> <title>JASP Test Page</title> </head> <body> <% response.write("<h1>JASP Test Page</h1>") %> </body> </html> 
  3. Access the following URL in your web browser:

    • http://linserv1.corp.com/test.asp

You should now see the text "JASP Test Page" in a large font in your browser window, as shown in Figure 10.6. If the browser window is empty (except for a title in the title bar), make sure you have completed the JASP install procedure successfully.

image from book
Figure 10.6: When the JASP engine is correctly installed, ASP code found in a file with the .asp extension is correctly executed to generate the text of the page
image from book
Apache::ASP: ASP-style programming in Perl on Apache without Mono

There's one other interesting ASP-on-Linux solution: an open-source Perl module called Apache::ASP . This sounds promising: it provides ASP's "object model" and embedding syntax for Apache. But there's a catch: it only supports one programming language for the code you embed in your web pages with it. And that language isn't Visual Basic, JScript or C#. It's Perl.

As you know from earlier chapters, we think Perl is a fine thing. But there are other solutions for embedding Perl in web pages. And folks looking for a Linux-hosted ASP solution are typically seeking to run existing ASP code written in Visual Basic. So Apache::ASP doesn't really meet our needs in this chapter except, perhaps, in the unlikely case that you already have developers who are using the .NET CLI version of Perl to create ASP.NET pages on a Windows server. Still, it is an interesting project, and you can find out more about it at www.apache-asp.org .

image from book
 


Windows and Linux Integration. Hands-on Solutions for a Mixed Environment
Windows And Linux Integration Hands-on Solutions for a Mixed Environment - 2005 publication.
ISBN: B003JFRFG0
EAN: N/A
Year: 2005
Pages: 71

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net