by Ken Mayer, SQA Engineer, dBASE, Inc.
Special Thanks to Gary White, Dennis Miller for editing ...
Note: This article was written for dB2K, but it should still work for dBASE Plus.
The purpose of this document is to help you set up the free (Open Source) Apache Web Server to run your dBASE application. The content of this document is from a combination of newsgroup messages and my own experience in setting up this web server.
There is a version of the free (Open Source) Apache Web Server included on your dBASE CD. If you want to find the latest version, you can download it from the Apache Software Foundation web site. On line documentation is also available from the same web site.
The first step is to install Apache. You can use the default directory or not. I installed to C:\APACHE.
Note: You can install Apache on Win 95, Win 98, NT, Windows 2K, Windows XP ... my test machine is Win 98, and I use Apache on that all the time ...
Before you modify the configuration file, it is probably a good idea to create a default HTML document that will be loaded when you have Apache running, and you open your browser to your root or primary web application directory. This directory would be the one that your HTML document(s) will be stored in.
You may wish to use a simple template or default file, which you can then modify later. The following could be copied and pasted to the file: INDEX.HTM, and stored in the root directory.
<HTML> <HEAD> <TITLE>dBASE Document Root Directory</TITLE> </HEAD> <BODY> So ... here we are ... </BODY> </HTML>
Save this as "INDEX.HTM" to the root directory for your dBASE web apps. This way, when testing, and you type in your browser (as mentioned later in the document):
There will be something in the directory that your browser recognizes ...
Next, you will need to edit the configuration file so Apache will know something about its environment. The configuration file serves a similar purpose to an executable's .INI file. The configuration file is "httpd.conf" and it is located in the \APACHE\conf\ directory. It might be wise to make a backup copy of this file before editing. Open the configuration file in your favorite text editor. Windows Notepad will do.
Much of the configuration file doesn't need to be changed. Note that any line beginning with a pound sign (#) is a commented line -- i.e., it is ignored by Apache. You may want to consider making a copy of lines you want to edit and remove the comment character from the your copy of the original line. That way you have something to refer to in case you made an error in you syntax, etc.
#Listen 3000 #Listen 18.104.22.168:80
The "Listen" entry is the IP address and port (separated by a colon) to which Apache will respond to HTTP requests. To use Apache on your local machine un-comment the last line and make changes as follows:
To use Apache on an actual web server, you will need to insert the server's hard-coded IP Address. Port 80 is the normal default port for HTTP. If you are using a different port, you will need to work with your system administrator to determine what it is, and set that number here.
Set this to your IP Address, if you have a permanent one. According to some, you can name this anything you want, such as "vdbapache" or "ken", and if you open your browser (see below under the 'testing ...' section), and enter "http://vdbapache" it should work as if you used "http://localhost". If you are running this on a local machine, set this to the same setting as the 'Listen' option shown above (without the port ...). I tend to just use "localhost" and not worry about it:
Set this to wherever you intend to store your documents, HTML, etc. NOTE the direction of the slash!!! This is the 'root' directory where INDEX.HTM mentioned above is stored.
There are a variety of issues on this one -- many documents refer to "Webroot", "Rootweb", "documentroot", etc., and they are all referring to this folder. The default location for this is under the folder that Apache is installed to, so you might want to use that. In that case, simply un-comment the line. If you wish to use a different folder (such as: C:\dBASEWeb), you want to change this:
<Directory> Options FollowSymLinks AllowOverride None </Directory>
This section is very important, in that it defines the default location of your executables ...
If you are using a structure where your .EXEs are in a different location from your HTML Documents, and your Data, and so on (as described later in this document), you might want to use the following.
<Directory "c:/apache/wwwroot/cgi-bin"> Options FollowSymLinks ExecCGI AllowOverride None AddHandler cgi-script .cgi .pl .exe </Directory>
Note the addition of the Options to include "ExecCGI"; and the addition of the "AddHandler" line -- this defines what scripts are acceptable to be executed (if this is not done either here, or in another section below, when your user clicks on a link for an .EXE, they will be asked if they wish to download it ... this is not what you want here ...).
Note: the "cgi-bin" folder is where your executables should go, and "wwwroot" is explained above -- if you use "c:/dBASEWeb", then that should be your path here, and your cgi-bin folder should be under that:
There is an option that can go on the line:
Options FollowSymLinks ExecCGI
called "Indexes" -- if that word is included after the word "Options", when you load your browser and no HTML document that falls into the list of options as a 'default' (see below), the browser will list all files in the root directory -- you probably do not want to do that ... (Special thanks to Gary White for pointing this out ...)
You can either modify this here, or as above (in the Directory section) by adding the line shown there.
#AddHandler cgi-script .cgi
The "#" is a comment -- remove it. Add to the end a space and ".exe" so the line looks like the one below -- the important thing is that this is either done in the directory section as shown above, or here -- if you do it in both places, it won't hurt anything, but it isn't strictly necessary:
AddHandler cgi-script .cgi .exe
You may want to find this entry:
And change it to:
DirectoryIndex index.html index.htm default.htm default.html
This gives you the option for the name of the startup .HTML document that will be looked for in the wwwroot folder. If a document by one of these names exists, it will be loaded automatically when you point your browser to your server ...
Save the configuration and exit the text editor you used to edit the document.
Using the Windows Explorer, go to the APACHE directory. In the main directory you will see APACHE.EXE -- double-click on this. A DOS Window will open. Don't close it! If you close that window, you deactivate the server. You can minimize it if you wish, but leave the window open.
Open your web browser and in the "Location" or "Address" entryfield/combobox, enter:
If you have a file in your documentroot folder (in the example above, C:/dBASEWeb) named "index.htm" or "index.html" then that document should appear. If you do not then you should get a listing of any files in that folder ... if you saved the file mentioned early in this document called index.htm, when you type the following in your browser, you should see that document:
If you see that document (which isn't very fancy ...), everything should be set up ok ...
If all is well, you now know it's working ... close your browser, and close the DOS Window that is running Apache. You will get a warning about it, just close it anyway ...
This assumes dB2K, but really it should work fine for VdB7.5 as well.
Do the full install of dB2K to ensure that the new registry entries are made. dB2K executables look for DB2KRUN.EXE in a different registry entry than VdB 7.x .EXE's.
Assuming you've done the default Apache install, just copy your application, i.e., "MyWebApp.exe" to:
C:\Program Files\Apache Group\Apache\cgi-bin
OR wherever you have defined the cgi-bin folder (i.e., "C:\dBASEWeb\cgi-bin", or "C:\dBASEWeb\MyApp", etc.).
To test a VdB .EXE directly, start Apache, and enter a URL like this in your browser's address window:
(Note: You can use "127.0.0.1" in place of "localhost", but which is easier to type?)
If you need an HTML form to launch the web app, copy it to
C:\Program Files\Apache Group\Apache\htdocs
Or whatever your root is, again, if you used "C:\dBASEWeb", then place the HTML file there.
Modify the <FORM> tag as appropriate, e.g.:
<FORM ACTION="/cgi-bin/MyWebApp.Exe" METHOD="POST" ...
At this point, to load the HTML document, you could use:
(Again, you could use "http://127.0.0.1/MyWebForm.htm", but why ...?)
There are many ways to look at this. There is no single one "right way" to do it ... don't let anyone tell you that your way is wrong, as long as it works.
One way of thinking of this is to keep each aspect of your application in a separate folder.
Example: Store the data in a different folder from the source code, the cgi-bin should be separate from the HTML, etc.
One possible setup might
|c:\dBASEWeb\cgi-bin||Executables ... (note: if the .exe needs any bitmaps, they should go here ...)|
You might even want to store the source code in subdirectories under the main source directory, and if you were really pushing it, you could store the executables under different directories under the cgi-bin directory ... just remember where for your app ...
This is all fine and dandy ... however, I get a bit frustrated with having to move my .EXEs every time I make a change ... so, I tend to keep the .EXEs in the same place as the source code, on the test machine. For final deployment to the server that will be used, that's a different matter, and that gets arranged with the ISP or the system administrator handling the machine in question.
My current setup is actually different. For testing purposes, I am keeping the source code in the same directory as the application (as noted above). The data, through the use of BDE Aliases, can be stored pretty much anywhere. I have different folders under "c:\dBASEWeb" for different applications .... this allows me to test different applications, and still have Apache recognize dBASEWeb as the main folder. Hence, in the Apache configuration file, I have the documentroot folder set to:
And I have the "CGI-BIN" entry set to the same location -- again, this is for testing purposes. The point however, is that a server that has several applications on it, can have those applications anywhere ... as long as they are "under" the main directory.
If you wanted to, you could store your applications in dozens of places on the same machine, and just remember the full path to everything. I'd rather not, but ... there are many ways to the mountain ...
This is from Michael Nuwer's website (http://www.nuwermj.potsdam/edu/dsamples/docs), where he has a lot of information about using Apache ...
Assuming that Apache is installed in C:\APache, the following run command (from the DOS prompt, or the 'Run' dialog that you can get by clicking on the 'Start' button) will install Apache to run as a service:
c:\Apache\Apache.exe -d c:\Apache -i
The command runs in a DOS Window, and modifies the registry. You should find the following registry key was added:
If that key has been added, Apache is set to run as a service. Versions such as 1.3.9 and later will set this service to run automatically, but you can change this in the Control Panel (Control Panel, Services ...). You should see Apache in the list of services on the left. If it is in the list, you can then start and stop Apache with the start/stop button. You can also set the server to run automatically (on boot) or manually. Use the startup button to modify this. If Apache is listed as a service, but the server will not run as a service, delete the above registry key, and re-run the command given ...
That's about the size of it. Again, you can find further documentation at the Apache Software Foundation web site to get answers for questions not answered here.