You need to enable CGI support to generate applications that use Embedded HTML.
To use Embedded HTML, you must have the following in place:
Project Specifications
- Your Visual Studio project must be a Native COBOL project using the Console Application output type or template.
- In the project properties, set the
Run-time Model on the
COBOL Link Settings tab to
Dynamic.
Server Specifications
Apache server:
You need to configure the server as shown below. This example was created with Apache 2.4.
- Enable mod_cgi
LoadModule cgi_module modules/mod_cgi.so
- Enable mod_env
LoadModule env_module modules/mod_env.so
- Specify a /cgi-bin script alias. For example:
<IfModule alias_module>
ScriptAlias /cgi-bin/ "${SRVROOT}/cgi-bin/"
</IfModule>
- Enable ExecCGI for the directory that contains your cgi executable. For example:
<Directory "${SRVROOT}/cgi-bin">
AllowOverride None
Options None
Require all granted
</Directory>
- Micro Focus Licensing Specifications
If you are using a version of the COBOL Run-Time System earlier than the one supplied with the latest
Visual COBOL, you must set the MFCES_INIT_LOCATION environment variable to point to your
ces.ini file. For example:
SetEnv MFCES_INIT_LOCATION "c:\programdata\micro focus\ces.ini"
IIS server:
The following instructions use Information Services Manager (IIS) 10.0 and Windows 10.
You can deploy in the default location for IIS,
C:\inetpub\wwwroot\cgi-bin. Alternatively, you can configure your project to create a site directory structure, and then configure your IIS server to
use that location. See
Deploying a CGI Application with Embedded HTML and the CGI samples available with Samples Browser.
Unrestricted CGI application present a security risk to your system. Because of this, you need to configure IIS to enable
CGI programs to execute. IIS runs under a special user name IUSR and you need to grant this user permissions to the site directory
structure.
IIS must be enabled in your Windows system - see the Microsoft documentation for instructions. You need to manually enable
CGI support as follows:
- Open the Control Panel and select
Programs.
- Click
Turn Windows features on or off.
- Enable
World Wide Web Services > Application Development Features > CGI.
To configure IIS to use a non-default installation location for the executables:
- Start IIS.
- In the
Connections pane, expand the machine name node.
- Right-click
Sites and click
Add Website.
- Specify a
Site name.
- In the
Physical path box, type the full path to the
site directory created by your Visual Studio solution such as
pathtosolution\site.
- It is recommended to change the
Port (for example, to 81) to avoid clashes with the default site. If the default site is not running, it is safe to use port number
80.
- Click
OK.
You also need to configure some IIS security features to enable CGI programs to execute in the site directory structure:
- In IIS, in
Connections, click on the top level machine name node and double-click
ISAPI and CGI Restrictions.
- Click
Add in the
Actions pane.
- Specify the full path name and the file name of your project's executable in the
ISAPI or CGI path text box - for example,
pathtosolution\site\cgi-bin\app.exe.
- Check
Allow extension path to execute, and click
OK.
- Expand
Sites, right-click the Web site you have just added, and click
Edit Permissions.
- Select the
Security tab.
- Click
Edit, then click
Add.
- Click
Locations, select the machine name, and click
OK.
- Enter
IUSR into the text box and click
OK.
IUSR now appears in the
Security pane with the following permissions enabled -
Read and & execute,
List folder contents, and
Read.
- Click
OK until these dialogs are closed.
- Restart the machine node in order to apply all of these changes - click
Restart in the
Actions pane.
You should now be able to debug your CGI application from the Visual Studio solution.
You also need to enable the IIS
web.config file in your site to work. The file controls the actions allowed by the web server on the directory.
- Start a command prompt with Administrator's privileges.
- Execute the following command:
%windir%\system32\inetsrv\appcmd.exe unlock config /section:system.webServer/handlers
You should receive the following message:
Unlocked section "system.webServer/handlers" at configuration path "MACHINE/WEBROOT/APPHOST".