噩夢
2001-11-18, 02:06 PM
一、先去 ActiveState (http://www.activestate.com/Products/ActivePerl/download.plex) 下載perl安裝套件
二、編輯apache\conf\httpd.conf這個檔案
三、找到 #AddModule mod_include.c mod_autoindex.c mod_dir.c mod_cgi.c mod_userdir.c
將前面的#去掉
四、找到 #!/usr/bin/perl 將他改成改成你的perl安裝目錄,例如 #!e:/perl/bin/perl.exe
五、找到
#
# "G:/Apache/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
<Directory "E:/www/cgi-bin">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
改成
#
# "G:/Apache/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
<Directory "E:/www/cgi-bin">
AllowOverride None
Options +ExecCGI
Order allow,deny
Allow from all
</Directory>
如果要讓別的使用者使用,只要在這段下面加上
<Directory "E:/www/nightmare/cgi-bin">
AllowOverride None
Options +ExecCGI
Order allow,deny
Allow from all
</Directory>
E:/www/nightmare/cgi-bin是其他使用者的cgi-bin目錄
記得要放在</IfModule>這行的前面
六、找到這段
# 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 command (see below)
#
# If you want to use server side includes, or CGI outside
# ScriptAliased directories, uncomment the following lines.
#
# To use CGI scripts:
#
將 #AddHandler cgi-script .cgi 前面的#去掉並改成 AddHandler cgi-script .pl .cgi
七、將你要執行的perl檔案,例如安裝完ActiveState後有個printenv.pl,內容是
#!/usr/local/bin/perl
##
## printenv -- demo CGI program which just prints its environment
##
print "Content-type: text/plain\n\n";
foreach $var (sort(keys(%ENV))) {
$val = $ENV{$var};
$val =~ s|\n|\\n|g;
$val =~ s|"|\\"|g;
print "${var}=\"${val}\"\n";
}
將第一行改成你放perl.exe的位置,例如本範例中我的perl.exe位置是e:/perl/bin/perl.exe
那就要改成
#!e:\perl\bin\perl.exe
八、重新啟動apache
九、完成...打入你自己的網址,例如http://localhost/cgi-bin/printenv.pl去測試看看吧..:D :D :D
我用過cgi,perl,apache在PCZONE上搜尋過,都沒找到類似的文章...
如果有重複發表,還請大家多多見諒...:p
我是Apache的新手,如果這篇發表有任何需要改正的地方或是有更高階的方法,還請各位前輩多多發表自己的意見
贊助商連結
二、編輯apache\conf\httpd.conf這個檔案
三、找到 #AddModule mod_include.c mod_autoindex.c mod_dir.c mod_cgi.c mod_userdir.c
將前面的#去掉
四、找到 #!/usr/bin/perl 將他改成改成你的perl安裝目錄,例如 #!e:/perl/bin/perl.exe
五、找到
#
# "G:/Apache/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
<Directory "E:/www/cgi-bin">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>
改成
#
# "G:/Apache/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
<Directory "E:/www/cgi-bin">
AllowOverride None
Options +ExecCGI
Order allow,deny
Allow from all
</Directory>
如果要讓別的使用者使用,只要在這段下面加上
<Directory "E:/www/nightmare/cgi-bin">
AllowOverride None
Options +ExecCGI
Order allow,deny
Allow from all
</Directory>
E:/www/nightmare/cgi-bin是其他使用者的cgi-bin目錄
記得要放在</IfModule>這行的前面
六、找到這段
# 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 command (see below)
#
# If you want to use server side includes, or CGI outside
# ScriptAliased directories, uncomment the following lines.
#
# To use CGI scripts:
#
將 #AddHandler cgi-script .cgi 前面的#去掉並改成 AddHandler cgi-script .pl .cgi
七、將你要執行的perl檔案,例如安裝完ActiveState後有個printenv.pl,內容是
#!/usr/local/bin/perl
##
## printenv -- demo CGI program which just prints its environment
##
print "Content-type: text/plain\n\n";
foreach $var (sort(keys(%ENV))) {
$val = $ENV{$var};
$val =~ s|\n|\\n|g;
$val =~ s|"|\\"|g;
print "${var}=\"${val}\"\n";
}
將第一行改成你放perl.exe的位置,例如本範例中我的perl.exe位置是e:/perl/bin/perl.exe
那就要改成
#!e:\perl\bin\perl.exe
八、重新啟動apache
九、完成...打入你自己的網址,例如http://localhost/cgi-bin/printenv.pl去測試看看吧..:D :D :D
我用過cgi,perl,apache在PCZONE上搜尋過,都沒找到類似的文章...
如果有重複發表,還請大家多多見諒...:p
我是Apache的新手,如果這篇發表有任何需要改正的地方或是有更高階的方法,還請各位前輩多多發表自己的意見
贊助商連結