<h1 style="margin:10px 0px; font-family:Helvetica,Arial,'Liberation Sans',FreeSans,sans-serif; font-weight:normal; line-height:40px; color:rgb(51,51,51); font-size:18px"> 什么是CGI ?</h1>
<ul style="padding:0px; margin:0px 0px 10px 25px; list-style:none; color:rgb(51,51,51); font-size:14px; line-height:20px; font-family:verdana,helvetica,arial,sans-serif"><li> <p style="margin-top:0px; margin-bottom:10px; text-align:justify">公共网关接口或CGI,Web服务器和一个自定义的脚本之间交换信息是是一组定义的标准..</p> </li><li> <p style="margin-top:0px; margin-bottom:10px; text-align:justify">CGI规范在由NCSA和NCSA定义的CGI保持如下:</p> </li><li> <p style="margin-top:0px; margin-bottom:10px; text-align:justify">公共网关接口或CGI,如HTTP服务器信息服务器的标准接口是外部网关方案.</p> </li><li> <p style="margin-top:0px; margin-bottom:10px; text-align:justify">当前版本CGI/1.1和CGI/1.2.</p> </li></ul>
<h2 style="margin:10px 0px; font-family:Helvetica,Arial,'Liberation Sans',FreeSans,sans-serif; line-height:40px; color:rgb(51,51,51); font-size:16px"> 网页浏览</h2>
<p style="margin-top:0px; margin-bottom:10px; color:rgb(51,51,51); font-size:14px; line-height:20px; text-align:justify; font-family:verdana,helvetica,arial,sans-serif"> 理解CGI的概念,让我们看看会发生什么,当我们点击一个超链接到浏览特定网页或URL.</p>
<ul style="padding:0px; margin:0px 0px 10px 25px; list-style:none; color:rgb(51,51,51); font-size:14px; line-height:20px; font-family:verdana,helvetica,arial,sans-serif"><li> <p style="margin-top:0px; margin-bottom:10px; text-align:justify">您的浏览器触点的HTTP Web服务器,即需求的URL ie.文件名.</p> </li><li> <p style="margin-top:0px; margin-bottom:10px; text-align:justify">Web服务器解析URL,如果发现该文件,然后发送回浏览器,否则发送错误消息表明您已经请求一个错误的文件.</p> </li><li> <p style="margin-top:0px; margin-bottom:10px; text-align:justify">Web浏览器从Web服务器的响应,并显示收到的文件或错误消息.</p> </li></ul>
<p style="margin-top:0px; margin-bottom:10px; color:rgb(51,51,51); font-size:14px; line-height:20px; text-align:justify; font-family:verdana,helvetica,arial,sans-serif"> 但是,它可能设立的HTTP服务器,因此,只要在某个目录中的文件被请求文件送回,而是作为一个程序执行,任何方案产出发送您的浏览器来显示。这个函数被调用的通用网关接口或CGI程序称为CGI脚本。这些CGI程序可以是一个Python脚本,Perl脚本,shell脚本,C或C+ +程序等.</p>
<p style="margin-top:0px; margin-bottom:10px; color:rgb(51,51,51); font-size:14px; line-height:20px; text-align:justify; font-family:verdana,helvetica,arial,sans-serif"> <br> </p>
<h2 style="margin:10px 0px; font-family:Helvetica,Arial,'Liberation Sans',FreeSans,sans-serif; line-height:40px; color:rgb(51,51,51); font-size:16px"> CGI架构图</h2>
<img alt="" src="https://beijingoptbbs.oss-cn-beijing.aliyuncs.com/cs/5606289-f0fdbddf832490361ed5be14c7b07f48.gif" style="height:auto; max-width:100%; vertical-align:middle; border:0px; color:rgb(51,51,51); font-family:'Helvetica Neue',Helvetica,Arial,sans-serif; font-size:14px; line-height:20px">
<span style="color:rgb(51,51,51); font-size:14px; font-family:verdana,helvetica,arial,sans-serif"></span>
<span style="color:rgb(51,51,51); font-family:'Helvetica Neue',Helvetica,Arial,sans-serif; font-size:14px; line-height:20px"></span>
<h2 style="margin:10px 0px; font-family:Helvetica,Arial,'Liberation Sans',FreeSans,sans-serif; line-height:40px; color:rgb(51,51,51); font-size:16px"> Web服务器的支持与配置</h2>
<p style="margin-top:0px; margin-bottom:10px; color:rgb(51,51,51); font-size:14px; line-height:20px; text-align:justify; font-family:verdana,helvetica,arial,sans-serif"> 进行CGI编程之前,确保您的Web服务器,支持CGI,它被配置为CGI程序处理。所有的HTTP服务器执行CGI程序都保存在一个预先配置的目录。这个目录被称为CGI目录,并按照惯例,它被命名为/ var/www/cgi-bin目录。约定CGI文件.cgi扩展名,但你可以保持你的Python扩展的文件.py.</p>
<p style="margin-top:0px; margin-bottom:10px; color:rgb(51,51,51); font-size:14px; line-height:20px; text-align:justify; font-family:verdana,helvetica,arial,sans-serif"> 默认情况下,Linux服务器配置只运行在cgi-bin目录中的/var/www脚本。如果你想指定的任何其他运行CGI脚本的目录,内容在httpd.conf文件中的下列行:</p>
<pre style="padding:9.5px; font-family:Monaco,Menlo,Consolas,'Courier New',monospace; font-size:13px; color:rgb(51,51,51); margin-top:0px; margin-bottom:10px; line-height:20px; word-break:break-all; word-wrap:break-word; white-space:pre-wrap; background-color:rgb(245,245,245)">AllowOverride None
Options ExecCGI
Order allow,deny
Allow from allOptions All</pre>
<p style="margin-top:0px; margin-bottom:10px; color:rgb(51,51,51); font-size:14px; line-height:20px; text-align:justify; font-family:verdana,helvetica,arial,sans-serif"> 在这里,我假设你有Web服务器,并成功运行,你可以运行任何其他CGI程序像Perl或shell等. |
|