Configure Apache in Windows to run CGI

Source: Internet
Author: User

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 ++!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.