How to run ASP on Linux

As the ASP is very easy to use, many companies choose ASP to develop their IT solution on Windows 2000 Server + ASP + MSSQL. However, this idea also have its disadvantages.  And when your are going to transfer to linux, you will find big problems. There are two ways to transfer ASP to Linux.

1. Use PHP instead of ASP. Change from MSSQL to Mysql. It is more stable solution. However, this takes more time and cost more.

2. Run ASP on Linux. Connect to separate MSSQL. The difficulty is Linux don’t support ASP.

Now I’d like to tell you how to run ASP on Linux. I uses redhat Linux + Apache + iASP + ASP to connect to MSSQL server.

My Runtime environment:

OS: Redhat DC Server 5.0 for x86 SP3
Webserver: Apache 2.0
runtime: iASP 2.1.1
java: Sun jdk
Database: Windows 2000 Server + MSSQL 2000

Configure Java runtime

In consideration of compatibility, I uses Sun 1.4.2 JDK. You can download iASP from Sun.

1. Installation

Unpack:

# sh j2re-1_4_2_15-linux-i586-rpm.bin
Unpacking...
Checksumming...
0
0
Extracting...
UnZipSFX 5.40 of 28 November 1998, by Info-ZIP (Zip-Bugs@lists.wku.edu).
inflating: j2re-1_4_2_15-linux-i586.rpm

Install:

# rpm -ivh j2re-1_4_2_15-linux-i586.rpm

2. Configure

The redhat 1.5.0 has a java build in

# whereis java
 java: /usr/share/java
 # java -version
 java version "1.5.0_04"
 Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)
 Java HotSpot(TM) Client VM (build 1.5.0_04-b05, mixed mode)

Change it to:

# ln -s /usr/java/j2re1.4.2_15 /usr/java/j2re1.4.2

Then edit /etc/profile.d/sun_java_sdk.sh:

#jdkroot=/usr/lib/jdk
 jdkroot=/usr/java/j2re1.4.2

Re-login to your server after saved it.Then check:

# su - root
 # java -version
 java version "1.4.2_15"
 Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_15-b02)
 Java HotSpot(TM) Client VM (build 1.4.2_15-b02, mixed mode)

Install iASP 2.1.1

You can download the iASP from here.

1. Unpack

# mkdir iASP_dir
 # tar xzvf iASP2.1.01.tar.gz -C iASP_dir/
 iasp21.tar
 install.sh
 README

2. Install iASP

# cd iASP_dir/
 # ./install.sh

Configure iASP with right java runtime path:

Please enter the full path to your JDK's bin directory.
 e.g. /usr/jdk1.1.6/bin, Q/q(quit), S/s(skip):
 /usr/java/j2re1.4.2/bin

Edit iASP installation path:

Enter the absolute directory under which Instant ASP should be installed.
 (./iasp21 will be created underneath.)
 > /usr/iasp
 Directory /usr/iasp does not exist,  create it (Y/N/Q)?
 > y

※Do please not use “/” after the path.

Configure the Web server. Here I uses Apache 2.0:

Would you like to configure your web server for Instant ASP now [Y/N]?y
 Do you want to continue (Y/N)? yPlease choose a servlet interface
 [1]  Instant ASP native servlet interface
[2]  Apache JServ
Enter a number [1/2]: 1
***** Please select a web server  *****
[1]  Netscape
 [2]  Apache
 [3]  Xitami
 [0]  Quit
Enter a number [0-4]: 2
*****    Please choice Apache version    *****
[1]  Apache 1.3.0
 [2]  Apache 1.3.1
 [3]  Apache 1.3.2
 [4]  Apache 1.3.3
 [5]  Apache 1.3.4
 [6]  Apache 1.3.6
 [7]  Apache 1.3.9
 [8]  Apache 1.3.11
 [9]  Apache 1.3.12
 [10] Apache 1.3.14
 [11] Apache 1.3.2X
 [12] Apache 2.X
 [0]  Quit
Note:  If you are using Apache Web Server higher version or have additional
 modules, such as Front Page Server Extensions, Raven SSL, or you are
 using Apache Strong Hold Server. Please configure iASP according
 to <iASP_Home>/bin/apache/source/readme.txt
Enter a number [0-10]: 12
Please enter the path to the Apache /conf directory >/etc/httpd/conf
setting for "Proxy host IP address" <127.0.0.1>
 setting for "Proxy port" <9098>
 setting for "Server manager port" <9095>
"httpd.conf"configuration completed.
Would you like to configure another web server (Y/N)?n
Configuration successful.
 You can access the Instant ASP documentation and samples
 from the virtual directory /iasp/

Result:

Server Information:iASP Path:          /usr/iasp/iasp21
 iASP Version:       2.1.01
 OS Name:            Linux  2.6.9-42.7AXsmp
 Host IP:            192.168.228.250
 Java Path:          /usr/java/j2re1.4.2_15
 Java Version:       1.4.2_15
 Java Vendor:        Sun Microsystems Inc.
 iASP License:       No License

3. Configure

You will find error if you start Apache now:

# service httpd start
 Start httpd:httpd: module "mod_iasp.c" is not compatible with this version of Apache (found 20020329, need 20020903).
 Please contact the vendor for the correct version.
 [Failed]

This is because the iASP module is encoded with 20020329 Apache. We need to configure a new module:

# cd /usr/iasp/iasp21/bin/apache/source/2.0/
 # apxs -i -c *.c

The new module should be placed here:

/usr/lib/httpd/modules/mod_iasp.so

Edit “/etc/httpd/conf/httpd.conf”:

#LoadModule iasp_module “/usr/iasp/iasp21/bin/apache/linux/2.0/mod_iasp.so”
 LoadModule iasp_module "/usr/lib/httpd/modules/mod_iasp.so"
Start Apache:
 # service httpd start
4. Start iASP

Start iasp proxy module:

# /usr/iasp/iasp21/start-server.sh &
 logging to stdout
 iASP/2.1.01 started
 [1] 13846

Listen port 9098:

# netstat -ln&#124;grep 9098
 tcp        0      0 :::9098                     :::*                        LISTEN

Stop iASP:

# /usr/iasp/iasp21/stop-server.sh
 iASP server stopped

Test ASP on Linux

1. Create an ASP test file

You can create a test.asp under “/var/www/html/” folder. The following is an simple example:

<html>
<head>
<title>Test iASP</title>
</head>
<body>
<%
Response.Write "<BR><h1>Congradulations!<BR>Instant ASP has worked for you!</h1>"
%>
</body>
</html>

2. Finished

ASP codes can run on Linux Apache if you see the following words:

Congratulations!

Instant ASP has worked for you!

Then you can edit configuration in httpd.conf to add virtual server, directory or index.asp.  You can even run PHP and ASP on one server.

Leave a Reply

Your email address will not be published. Required fields are marked *