0% found this document useful (0 votes)
86 views21 pages

dBASE 2019 and Apache 24x - Configuration Guide

The document provides instructions for configuring Apache 2.4.3 on Windows 10 to run CGI programs developed with dBASE 2019. It describes downloading and extracting Apache, editing the httpd.conf file to change ports and enable CGI, adding handler mappings for CGI file extensions, and creating a simple "test.exe" program to test the CGI configuration. The document aims to explain each step needed to set up the Apache/dBASE development environment on Windows.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
86 views21 pages

dBASE 2019 and Apache 24x - Configuration Guide

The document provides instructions for configuring Apache 2.4.3 on Windows 10 to run CGI programs developed with dBASE 2019. It describes downloading and extracting Apache, editing the httpd.conf file to change ports and enable CGI, adding handler mappings for CGI file extensions, and creating a simple "test.exe" program to test the CGI configuration. The document aims to explain each step needed to set up the Apache/dBASE development environment on Windows.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

Running dBASE®

2019 Web
Application on
Apache 2.4.3 for
Windows®
Michael Rozlog
This write-up will cover how to configure Apache 2.4.3
for CGI communication on Windows® 10 operating
system.

dBase, LLC
Table of Contents
Getting Apache 2.4.x .................................................................................................................................. 2

Configure Apache 2.4.x – Changes to the httpd.conf file ..................................................................... 4

Configure SSL in Apache ........................................................................................................................ 10


Configure CGI Settings in Apache 2.4.x ............................................................................................... 11
Create simple dBASE 2019 Web Application....................................................................................... 13

Producing a Build in dBASE 2019 ......................................................................................................... 16

Executing the MySimpleWeb.exe CGI program.................................................................................. 19

1
Getting Apache 2.4.x
1. First, you need to download the latest version of Apache HTTPD project. For this
example I will be using httpd-2.4.23-x86-vc14.zip

Finding a Windows version of Apache 2.4.x is sometimes difficult. We have found that
ApacheHaus keeps things up to date and patches very frequently. It is recommended
that you use the latest version and use the VC14 or above C/C++ runtime from Microsoft.

This build can be found at ApacheHaus:

https://www.apachehaus.com/cgi-bin/download.plx

This is the latest as of 2016 and is built for 32-bit operation and is compiled with Visual
C runtime from Microsoft 2014 edition.

I have uncompressed the .zip file and have it in a directory

In the Windows file explorer, it looked like:

2
a. There was no installer, therefore I copied the Apache24 directory to my C:\ and
will be using that as my base of my product

b. You must have the proper Microsoft C/C++ Runtime installed for this version of
Apache to work on a Windows 10 machine

Note: Binaries built on Visual C++ 2015 x86 do not run on Windows XP or
Windows Server 2003 These binaries were built with Visual Studio® 2015 x86, be
sure to install the required Visual C++ 2015 x86 Redistributable Package,
download from;

c. Now that I have copied the Apache24 directory to my root of C: I can now start
to manipulate it to work, as I desire.

d. This is what the directory looks like when moved:

3
I also recommend that you create a cmd.exe (Command Windows) to help interaction
with Apache. This can be easily done by clicking the File and selecting the command
windows.

I did mine as Administrator and this is what was produced:

However, before I kick off the Httpd.exe I want to change my port number for this
webserver.

Configure Apache 2.4.x – Changes to the httpd.conf file

2. Changing the port number to be used by Apache 2.4 HPTTD process

Load the C:\Apache24\conf\httpd.conf file in your favorite editor; I will be using


Notepad++ for this operation

4
I’m going to scroll down to the line that states: Listen 80

I’m going to change that port number to 80, so it should state Listen 8080

After that change another small change need to be made:

5
Scroll down to the ServerName line, it will say localhost:[port number] We need to
match our port number from above, in this case 8080.

ServerName localhost:8080

a. Now using the Command window we opened we can now type httpd.exe in the
window to kick off Apache:

6
You may get a Windows Firewall exception dialog. Since we are opening the port to
communicate the HTTP communication traffic we need to allow this… Press the Allow
access button.

Once the exception is create the window will return as such

7
Now we should test to see if our Apache webserver is up and running. Open a Browser
window and type the following:

http://localhost:8080 and hit return

I’m using the ApacheHaus build of the binaries so the return page looks like:

8
The big take-away is the It Works, meaning that Apache is responding.

b. There are additional commands that you can do with Apache when you start the
server:

Note: The following is taken from Apachehaus readme

You can shut down Apache by pressing Ctrl+C (It may take a few seconds)

To Install Apache as a service:

In most cases you will want to run Apache as a Windows Service.


To do so you install Apache as a service by typing at the command prompt [1];

httpd -k install

You can then start Apache by typing

httpd -k start

9
Apache will then start and eventually release the command prompt window.

[1] You have to run the command prompt as Administrator in Windows


Vista/7/2008/8/8.1/10/2012/

Other Command line options:


Stop Apache httpd -k stop
Restart Apache httpd -k restart
Uninstall Apache Service httpd -k uninstall
Test Config Syntax httpd -t
Version Details httpd -V
Command Line Options List httpd -h

Configure SSL in Apache


3. There are some instances when the SSL ports for Https support can cause issues. In
other words, the standard port of :443 may be in use by some other program or use. If
that is the case, you need to change that to a new port number.
a. The two (2) files that you need to be concerned with are:

10
File #1: httpd-ahssl.conf
File #2: httpd-ssl.conf
b. Open both of these files and change the :443 to another port number in my case it
would be :444. Make sure to change each one of them to ensure proper start of
the httpd server/service.
c. Go to the Prior section under the a. section and try to get the httpd.exe service up
and running. Once that is running proceed to the next section.

Configure CGI Settings in Apache 2.4.x

4. First, stop the Apache Httpd.exe service running in your command window. This can
be done by pressing the ctrl-c

a. Next back in the httpd.conf file, we need to enable the CGI

Go to the Document Root section (DocumentRoot "${SRVROOT}/htdocs"):

# DocumentRoot: The directory out of which you will serve your

# documents. By default, all requests are taken from this directory, but

11
# symbolic links and aliases may be used to point to other locations.

b. Look for the line that states:

Options Indexes FollowSymLinks

c. Now change the line to read:

Options Indexes FollowSymLinks ExecCGI

d. Now look for the line:

#AddHandler cgi-script .cgi .pl

e. Remove the # and add .exe to the end of it:

AddHandler cgi-script .cgi .pl .exe

In the </Directory for the Document root add

AddHandler cgi-script .cgi .pl .exe

f. After the </Directory> for the Document root we need to add the following
section:

<Directory “c:\apache24\cgi-bin”>
Options FollowSymLinks ExeCGI
AllowOverride None
AddHandler cgi-script .cgi .pl .exe
</Directory>

g. Now do a File Save of the configuration


h. Now restart the httpd server, is should look like the following:

12
i. Type httpd in the command prompt, if it is running there should be no errors.

Create simple dBASE 2019 Web Application


1. Create a quick .exe file
1. .exe files are used by the CGI-exe interface as the file extension to use for the interaction
2. I’m going to create a test.exe file – this is just a simple file to see if we got things
working.
3. Create a new file in Documents folder
a. Start dBASE
b. I’m under the dBASE2019/web folder/ that I created for this example.
c. In the Navigator go to the Programs tab and click new program, this will open
up the Source Editor
d. Part of the web programming used by dBASE uses objects that have the source
included with the product. These classes are used by dBASE to make
programming for the Web easier. The classes need to be in the same directory as
the deployed .exe used by the CGI (Common Gateway Interface) program that
runs the dBASE programs. The code, classes, examples can be found here:

The Web Classes are located in the following folders:


C:\users\<username>\Documents\dBASE\dBASE2019

13
\Web
Classes // the class code is here

Samples
Source // sample source is here
cgi-bin // sample executables are here
htdocs // sample HTML is here
data // sample data is here

e. Add the following lines:

Param cParam1

Set talk OFF // turn off interactive mode

Set century ON // Y2K

Try // Error trap entire CGI applet.

////// Create new instance of the Web Class

set procedure to WebClass.cc additive

oCGI = new CGISession()

////// Connect to the Web Server (StdIn/StdOut)

myc = version(1)

oCGI.Connect()

ocgi.StreamHeader("Hello from dBASE!")

ocgi.StreamBody()

ocgi.streamDetail("You are using -> " + myc) ocgi.StreamFooter()

catch (exception e)

oCGI.errorPage(e)

endtry

////// all done

Quit

14
f. After that, do a File|Save As…

Saved it as MySimpleWeb.prg

g. This will save

15
h. After the Save now do a Compile and make sure it is in good shape.

Producing a Build in dBASE 2019


4. Now we have to build an .exe out of it.
a. We could use the command windows and type in the build command but I will
show how to use the Project Explorers power to produce the correct .exe
b. In dBASE, click the File|New Project

16
In the Program Files pane on the left side we are going to right mouse click on
Program and select the Add Files to Project… option

We will point to the MySimpleWeb.prg and press the open button

Turn on: 2 UAC OFF

Pick the MySimpleWeb.prg as the main program.

The Target .exe Filename is: MySimpleWeb.exe

Now check the ‘Web application’ option under Project tab. This puts the WEB
part in the BUILD command.

NOTE: When run, an application built using the WEB keyword will take
advantage of optimizations built into PLUSrun.exe, which allows it to
load faster and use fewer resources than a non-WEB application

No other options are needed, so you can click on the toolbar icon with the box
exe on it.

You should see the following:

17
The project compiled and was output to a writable directory.

c. Now copy the file to the (default location) C:\Apache24\htdocs

18
Copy the MySimple.exe and WEBCLASS.co to the c:\Apache24\htdocs
directory

d. This is what you will see:

Executing the MySimpleWeb.exe CGI program

5. Now we should try to run the .exe file in a browser\


a. In the Browser address edit put: localhost:9091/MySimpleWeb.exe

19
b. Press the enter key

The simple executable only returns the runtime version back in a string. This is a
very simple hello world type application.

20

You might also like