您的位置:首页 > 理论基础 > 计算机网络

http与cgi

2016-09-28 18:23 211 查看
首先我先给大家解释cgi是什么?cgi定义:cgi(Common Gateway Interface)是http服务器与你的机器或其它机器上的程序进行“交谈 ”的一种工具,其程序必须运行在网络服务器上。cgi处理程序的步骤:1:通过网络把用户请求发送到服务器2:服务器接受用户请求并交给cgi程序处理3:cgi程序把处理结果传回给服务器4:服务器把结果送回到用户注意:cgi程序不是放到服务器上就能顺利运行,需要对所使用的服务器进行配置。(下面是我对http服务器的一些配置)(1)yum install prel-CGI.noarch (下载第三方软件去支持cgi和http能够合作)(2)到http默认发布目录/var/www/html建立一个目录cgi(自己可以随便建立任意一个目录),在cgi目录下写index.cgi这个文件,文件内容如下(显示时间):#!/usr/bin/perlprint "Content-type: text/html\n\n";print `date`;(3)到/etc/httpd/conf.d下有一个default.conf(如果没有这个文件可自行建立)文件内容如下Virtualhost _default_:80> Documentroot "/var/www/html" customlog "logs/default-vhost.log" combinedWed Jun 17 18:24:24 CST 2015 require all granted Options +ExecCGI AddHandler cgi-script .cgi (4)给/var/www/html/cgi/index.cgi一个执行权限及改变它的安全上下文[root@client ~]# chmod +x /var/www/html/cgi/index.cgi[root@client ~]# ls -l /var/www/html/cgi/index.cgi-rwxr-xr-x. 1 root root 67 Jun 17 16:49 /var/www/html/cgi/index.cgi[root@client ~]# semanage fcontext -a -t httpd_sys_script_exec_t '/var/www/html/cgi'[root@client ~]# restorecon -RvvF /var/www/html/cgi/[root@client ~]# ll -Zd /var/www/html/cgi/drwxr-xr-x. root root system_u:object_r:httpd_sys_script_exec_t:s0 /var/www/html/cgi/(5)这样就可以在浏览器中看到结果Wed Jun 17 18:24:24 CST 2015 ~
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  http cgi
相关文章推荐