CGI in a glance
来源:互联网 发布:绘制网络拓扑图软件 编辑:程序博客网 时间:2024/06/03 19:47
http://www.jdon.com/idea/cgi.htm
The Common Gateway Interface (CGI) is a standard protocol that defines how webserver software can delegate the generation of webpages to a console application. Such applications are known as CGI scripts; they can be written in any programming language, although scripting languages are often used.
Drawbacks
Calling a command generally means the invocation of a newly created process. Starting up the process can take up much more time and memory than the actual work of generating the output, especially when the program still needs to be interpreted or compiled. If the command is called often, the resulting workload can quickly overwhelm the web server.
The overhead involved in interpretation may be reduced by using compiled CGI programs, such as those in C/C++, rather than using Perl or other scripting languages. The overhead involved in process creation can be reduced by solutions such as FastCGI, or by running the application code entirely within the webserver using special extension modules.
Alternatives
Several approaches can be adopted for remedying this:
- The popular Web servers developed their own extension mechanisms that allows third-party software to run inside the web server itself, e.g. Apache modules, Netscape NSAPI plug-ins,IIS ISAPI plug-ins.
- Simple Common Gateway Interface or SCGI
- FastCGI allows a single, long-running process to handle more than one user request while keeping close to the CGI programming model, retaining the simplicity while eliminating much of the overhead CGI incurs by creating a new process for each request. Unlike converting an application to a web server plug-in, FastCGI applications remain independent of the web server.
Alternatives
PHP
JSP
ASP
Python: The Web Server Gateway Interface defines a simple and universal interface between web servers and web applications or frameworks for the Python programming language.
Hello, CGI
apache in redhat
http://www.redhat.com/docs/manuals/linux/RHL-9-Manual/ref-guide/index.html
http://httpd.apache.org/docs/2.2/howto/cgi.html
1. start up apache
/etc/rc.d/init.d/httpd start
2. write cgi script, under ScriptAlias dir
Default cgi script is put under /var/www/cgi-bin
/etc/httpd/conf/httpd.conf
ScriptAlias /cgi-bin/ /var/www/cgi-bin
Perl script: hello.cgi
Shell script: getdate.cgi
File permissions
Remember that the server does not run as you. That is, when the server starts up, it is running with the permissions of an unprivileged user - usually nobody, or www - and so it will need extra permissions to execute files that are owned by you. Usually, the way to give a file sufficient permissions to be executed by nobody is to give everyone execute permission on the file:
chmod a+x first.pl
Also, if your program reads from, or writes to, any other files, those files will need to have the correct permissions to permit this.
3. request through browser
http://host/cgi-bin/hello.cgi
http://host/cgi-bin/getdate.cgi
Directory
- CGI in a glance
- A glance at iptables in Openstack
- A Glance At Garbage Collection In Object-Oriented Languages
- A Glance At Garbage Collection In Object-Oriented Languages
- Django at a glance
- Maya at a Glance
- A glance on MongoDB
- A glance on RPC
- A glance on VDBI
- ADO at a glance
- Scrapy at a glance
- lighttpd start and running a cgi written in C
- Django at a glance 笔记
- Maya 8 at a Glance
- scrapy at a glance 研读
- A Glance at Web Application Security
- ADO.NET Connection Pooling at a Glance
- ADO.NET Connection Pooling at a Glance
- jQuery的福音:EasyUI如期而至
- 多线程服务器的适用场合
- ASCII 、GB2312、GBK、GB18030、unicode、UTF-8字符集编码详解
- 常用sql命令列表 自己整理的
- Protel DXP 1:1打印
- CGI in a glance
- 启动oracle10监听器错误:本地计算机上的OracleOraDb10g_home1TNSListener服务启动后又停止了
- FlashBuilder_4_Plugin_LS10.exe 安装出错的问题
- Shader Debug
- redhat 安装 yum
- [技术讨论]建模工具的使用到客观评价
- Howto Install Just A Single Module
- linux安装mysql(详细)
- 纯 Java 实现播放 mp3 音乐