Using Borland Enterprise Server Web Edition with Delphi and C++ Builder web server applications

By: John Kaster

Abstract: John K shows quick steps for replacing Microsoft Internet Information Server with Apache in BES Web Edition for Delphi and C++ Builder cgi applications

We recently purchased a Pentium 4 1.7 Ghz machine to upgrade the server for CodeCentral here on the Community site from a Pentium II 400 Mhz. The (unfortunately) somewhat novel occurence of having a new machine to configure provided me an excuse to investigate some new solutions.

Replacing IIS with Borland Enterprise Server Web Edition

Because we were putting in a new machine, I figured it was time to re-evaluate the web server options and operating system for it. The current machine for CodeCentral is running Windows NT Server and Microsoft Internet Information Server (IIS). As is the case with many people hosting web sites, I've been concerned with the amount of attacks IIS receives, the frequency of exploit discoveries, and the subsequent security patches for them, so I thought evaluating a different web server solution was in order, particularly since Borland now provides a web server solution.

The Borland Enterprise Server (BES) Web Edition includes both Apache and Tomcat in its installation. It seemed to me it would make a lot of sense to use BES to host CodeCentral on the new server box. There were a couple benefits to this:

  • I could start using BES to host Community-site applications, giving me lots of management, load balancing, and expansion options for the future, particularly when we start adding future JBuilder projects to the mix
  • Any knowledge gained from using BES will benefit me for multiple platforms, not just Windows
  • A Windows 2000 Server license isn't required to run IIS with more than 10 users, which saves on licensing fees
  • I could leave the existing Windows 2000 Pro on the new server machine we purchased

Installing BES

Put the BES CD in your CDROM drive, and launch the Windows installer. You can install BES wherever you want. I did not install it to its default directory, but instead used d:/Borland/bes. After it's installed, launch the BES Console, and log in.

Starting Apache

BES Console Login
The default password is "admin"

After logging in, the console will take a little while to scan your network and look for available servers. After it's done, we need to start Apache in the application server. Browse to:

    Management Domain
      Enterprise Servers
        SERVERNAME (the name of the application server you just installed)
          Partitions
            Services

Then right click on Apache and select start.

Staring apache
Starting Apache

The status icon will change from two horizontal lines to a green check. If you encounter any errors starting Apache, you can click on the "Logs" tab and see what Apache is reporting. It's a good idea to start Apache first before reconfiguring it as discussed shortly, so you can make sure there's no default configuration errors occuring after the install.


Apache running

Supporting Delphi and C++ Builder CGI applications

The config file for Apache, httpd.conf, is several levels deep in the bes/var path. You should be able to find it in bes/var/servers/SERVERNAME/apache1/conf, where SERVERNAME is the name of your server.

For CodeCentral's CGI application to work, I made some changes to the configuration file. First, I added .EXE files as a valid CGI extension. You can search your config file for "AddHandler" to find the correct spot:


    #
    # AddHandler allows you to map certain file extensions to "handlers",
    # actions unrelated to filetype. These can be either built into the server
    # or added with the Action command (see below)
    #
    # If you want to use server side includes, or CGI outside
    # ScriptAliased directories, uncomment the following lines.
    #
    # To use CGI scripts:
    #
    AddHandler cgi-script .exe

Configuring "virtual directories"

Second, I needed to set up some aliases for CodeCentral to work the same way it did when it was running under IIS. I had an images virtual directory, and a CodeCentral virtual directory, so the following alias definitions accomplish this for me with Apache. Just search for your other Alias definitions to find the correct spot:


    Alias /images/ "d:/images/"
    <Directory "d:/images">
        Options Indexes MultiViews
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>

    Alias /codecentral/ "d:/ccweb/"
    <Directory "d:/ccweb">
        AllowOverride None
        Options ExecCGI
        Order allow,deny
        Allow from all
    </Directory>

Setting up redirection

I am sure Apache has other ways to do this, but I'm taking what I think is the simplest way to set up a default redirection for web server. The DocumentRoot property will tell you the location of your default document for the web server. I modified this index.html file to automatically redirect people to the CodeCentral server app by using an html metatag in the HTML file. That way, if someone happens to go to the machine directly, they won't get the default "Welcome to Borland Enterprise Server" html page, but will actually end up at the CodeCentral server.


<html>
<head>
<title>Borland CodeCentral</title>
<meta http-equiv="refresh" content="0; url=/codecentral/ccweb.exe/home">
</head>

<body>
<h1>Welcome to CodeCentral!</h1>
<p>If you don't get redirected automatically, you can
<a href="/codecentral/ccweb.exe/home">click here</a> for the CodeCentral home page.</p>
</body>
</html>

The meta tag setting for "refresh" and its URL provides the redirection functionality in the above HTML file.

If you know a better way to set up this redirection with Apache (I'm sure there probably is one) please either comment on this article or email me. Thanks!

Restarting Apache with configuration changes

After those steps, you can restart the Apache server by right mouse clicking on it in the BES console, and selecting restart. Then, when you go to http://localhost in a browser on the local machine, you should get automatically redirected to the URL specified in your default document metatag.

After that, you're ready to continue your Delphi and C++ Builder web development as usual, except you'll be using Borland Enterprise Server instead of Microsoft Internet Information Server.

This article just scratches the surface of what can be done with BES. In fact, it hardly touches on it at all, since my first step was in simply getting CodeCentral running on the Apache server hosted in BES. At BorCon 2002, you will be able to find out much more about BES. I hope to see you there.

John Kaster, Borland Developer Relations.


Server Response from: ETNASC03