A CGI Web Server is an *.exe file - ISAPI and NSAPI Web Servers are *.dll files.
*.dll Web Servers are better (faster and more efficient) for high volume sites, but they are very difficult to debug because the main Web Server (IIS, Netscape, and the like .. but not Apache) must be shut down each time a new *.dll is compiled. As a result, it is usually easier to create a CGI server first and convert it to an *.dll latter. (Only the project (*.dpr) file is different.) (Below, I provide an application that automatically shuts down IIS when new dll's are compiled.)
See C:\Program Files\BORLAND\Delphi5\Demos\Webserv for a demo where the CGI (*.exe) and ISAPI (*.dll) applications use a common module (*.pas file).
For an overview, see Creating Internet server applications in the Delphi help. (In the help contents, it is under Writing Distributed Application. You can also launch it via Start / Programs / Delphi / Help / Developing Distributed Applications, but then many of the links won't work.)
Running your program under IIS
The precise steps vary depending on which operating system and which version of IIS you are using.
On my XP system, each directory under
c:\Inetpub\wwwroot\can be individually accessed and configured. I do not suggest assigning aliases to directories in that path - use aliases only if your executables are in another path.
c:\Inetpub\wwwroot\xyz\WebCGI.exe c:\Inetpub\wwwroot\xyz\WebCGI.dllare accessed in a browser as
http://localhost/xyz/WebCGI.exe http://localhost/xyz/WebCGI.dllIf the web server is not on the local machine, but it is on the local intranet, replace localhost with either the machine name or it IP address.
http://MachineName/xyz/WebCGI.exe http://192.168.0.100/xyz/WebCGI.exeTo simplify debug, you want Delphi to automatically store the compiled output in the appropriate directory. To configure this, from the Delphi menu, set
Project / Options... / Directories / Output Directory
Running your program under Apache on a Windows platform
Apache will run CGI exe's and ISAPI dll's. However, because the ISAPI dll's are reloaded each time that they are called, they run at the same speed as an *.exe. (Thus, IIS is much faster.)
By default, all *.exe files should be placed in
c:/program files/apache group/apache/cgi-bin/In order to create your own directories, you need to modify one of 3 configuration files (your choice).
# This allows ISAPI dll's AddHandler isapi-isa .dllHowever, I was never able to get ISAPI dll's to work in cgi-bin or any other alias created with ScriptAlias.
This code works with *.exe files and *.dll files.
After modifying a configuration file, you need to restart Apache. Assuming that Apache is being run from a command prompt, running the following command in a separate command window will restart it. (In addition, the Service Name option is required when Apache is run as a service.)
apache -k restartSometimes, the restart is not reliable - you must actually, close the Apache window and then restart it.
To simply test a configuration file, use
How to automatically update dll's
How it works - This Delphi program checks a sub-directory every 5 seconds. When a file is found, it shuts down the server and moves the file(s) to the main directory.
With this program, dll's are just as easy to test as CGI files.