本例不考慮iptables 及SELINUX情況下 #/etc/init.d/iptables stop #setenforce 0
#vim /etc/httpd/conf/httpd.conf
#ScriptAlies 虛擬目錄 實體目錄(當http://serverip/cgi-bin 就會導向實體目錄/var/www/cgi-bin/執行) ScriptAlias /cgi-bin/ "/var/www/cgi-bin/" #針對實體目錄/var/www/cgi-bin/做權限處理 <Directory "/var/www/cgi-bin"> AllowOverride None Options Execcgi -->重要!!把原本none改成Execcgi才可執行 AddHandler cgi-script .cgi .pl --->接受以 .pl 或 .cgi的副檔名的檔案執行 Order allow,deny Allow from all </Directory>
#!/bin/bash printf "Content-type: text/html\n\n"; printf "Hello Andy";
$links http://YourIP/cgi-bin/index.cgi