Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to build the development environment of C language CGI and Apache server

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

In this issue, the editor will bring you about how to build the development environment of C language CGI and Apache server. The article is rich in content and analyzes and describes it from a professional point of view. I hope you can get something after reading this article.

I saw cgi while studying the c language gui this afternoon. I spent some time looking for the gui framework of c language before, and I also found a few that are more satisfactory for the time being, but after seeing cgi, I think I can give it a try. Some experience in web development might be easier. Google for a while, now there is very little discussion about cgi, especially the c language cgi. After some effort, we have finally built a usable development environment and run the program. Let's briefly share the process of my experiment. It's actually a very simple thing.

First, the tools and code you need to use:

C language compiler, I use IDE (Vsiual C++ 2008 Express Edition, hereinafter referred to as VC2008), other compilers (gcc, tcc, etc.) can also

Apache server. I use the Apache server (download address) included in USBWebSever. This is an AMP server suite that can be used without installation, while a locally installed Apche server can also be used.

Cgic (download address), which is a cgi library written in ANSI C. here we use the code it provides to test our running environment, and other standard c code is also available.

Next, compile the cgi program in C language.

Build an empty Visual C++ project in VC2008

Extract cgic.h, cgic.c and cgictest.c files from the cgic code package you just downloaded and add them to the new project

Open the property page of the current project (right-click the project name in solution Explorer and select Properties from the menu), find the preprocessor definition in the configuration properties-Calgam Cellular processors-preprocessor, and add WIN32

At this point, you can press F7 to build the solution, and VC2008 starts compiling the code and links to generate the executable file (.exe). Give some warnings and ignore them. So the cgi program is done.

Then, configure and start the Apache server.

For the locally installed Apache service, you need to modify several contents of the configuration file httpd.conf (see article link), as follows:

ScriptAlias / cgi-bin/ "E:/apache2/Apache2/cgi-bin/" AllowOverride None Options ExecCGI Order allow,deny Allow from all AddHandler cgi-script .exe .pl .cgi

The E:/apache2/Apache2/cgi-bin/ should be changed to the directory where you put the cgi program in the original. You may need to restart the Apache server after modifying the httpd.conf

For USBWebSever, there seems to be no need to modify the httpd.conf. If necessary, you should modify the httpd.conf analogy in the settings directory, and do not modify the text such as {rootdir} / cgi-bin/! Once modified, double-click USBWebSever.exe to start the Apache server.

* copy the cgi program (.exe file) you just generated into the / cgi-bin/ directory mentioned above, and change the file name * * to index.cgi. The USBWebSever,cgi-bin directory should be the cgi-bin directory under the root directory (if you don't want to create a new one), not the cgi-bin directory in the same directory as USBWebSever. My directory structure is like this.

Open the browser and type http://localhost:8080/cgi-bin/index.cgi (the address depends on your own specific settings), and you can see that the cgi program is already running.

The above is the editor for you to share how to build the C language CGI and Apache server development environment, if you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report