Linux服務器---apache支持cgi

Apache支持cgi    html

一、打開Apache配置文件httpd.conf,搜索「cgi」,找到下面的一段,去掉「addhandler」前面的「#「,這樣就開啓了Apache的cgi功能瀏覽器

[root@localhost ~]# gedit /etc/httpd/conf/httpd.confide

# AddHandler allows you to map certain file extensions to "handlers":學習

# actions unrelated to filetype. These can be either built into the server測試

# or added with the Action directive (see below)ui

#spa

# To use CGI scripts outside of ScriptAliased directories:code

# (You will also need to add "ExecCGI" to the "Options" directive.)server

#htm

AddHandler cgi-script .cgi

 

二、cgi的目錄在「/var/www/cgi-bin/」,在這裏建立一個測試文件「test.cgi」輸入內容以下

[root@localhost ~]# touch /var/www/cgi-bin/test.cgi

#!/usr/bin/perl

print "Content-type: text/html\n\n";

print "hello cgi";

 

三、將「cgi-bin」的權利改成777

[root@localhost ~]# chmod R 777 /var/www/cgi-bin

 

四、在瀏覽器輸入「127.0.0.1/cgi-bin/test.cgi」能夠看到下面的結果

       

 

 

 

 作了一個Linux學習的平臺,目前出來一個雛形,各位能夠參考使用
連接:https://pan.baidu.com/s/1GOLVU2CbpBNGtunztVpaCQ  密碼:n7bk

相關文章
相關標籤/搜索