Configure Apache in Windows to run CGI
Introduction:
I recently tried CGI and wanted to try its efficiency. But after a long time, I still couldn't run a simple CGI program.
But today I made another mistake. Through repeated tests, I found that:
The EXE generated after being compiled and connected using turboc2 cannot be run in Apache.
Only the EXE created by VC can be used.
Ah, how can I get dizzy? In order to reduce the detours for beginners, I will record some of my experiences today.
Body:
Background:
Operating System: Windows
Webserver: apache2.0
Browser: ie6.0
Process:
Install Apache first
Configure httpd. conf to support CGI written in C language.
The process is as follows:
1. Configure Apache
The main configuration is as follows:
ScriptAlias/cgi-bin/"E:/apache2/apache2/cgi-bin /"
<Directory "E:/apache2/apache2/cgi-bin">
AllowOverride none
Options execcgi
Order allow, deny
Allow from all
</Directory>
Addhandler CGI-script. EXE. pl. cgi
Note:
1) "E:/apache2/apache2/cgi-bin/" The AGI-bin directory under Apache installed for you. Use/to separate the parent directory and sub-directories.
2) addhandler is like installing EXE, PL, and CGI File suffix drivers, however, I will perform the following operations to change the compiled EXE file to a file with no file suffix or any type of file suffix.
2. Write a cgi of helloworld. C. The Code is as follows:
A simple example is as follows:
Code:
# Include <stdio. h>; void main (void) {printf ("/N"); printf ("Hello, world! Compiled by VC ++! /N ");}
[Ctrl + A select all]
Create helloworld.exe and copy it to the cgi-bin directory of Apache.
Note:
1) tens of millions of characters must be compiled using VC. The reason may be that the latter is a 16-bit compiler and the former is a 32-bit compiler.
2) an empty row must be output first.
3.
Http: // localhost: Port/cgi-bin/helloworld.exe
View results
Hello, world! Compiled by VC ++!