======利用Apache web server 執行CGI程式====== 本例不考慮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/做權限處理 AllowOverride None Options Execcgi -->重要!!把原本none改成Execcgi才可執行 AddHandler cgi-script .cgi .pl --->接受以 .pl 或 .cgi的副檔名的檔案執行 Order allow,deny Allow from all ======編寫簡單cgi腳本====== #!/bin/bash printf "Content-type: text/html\n\n"; printf "Hello Andy"; ======測試====== $links http://YourIP/cgi-bin/index.cgi ======參考資料====== * [[http://lamp.linux.gov.cn/Apache/ApacheMenu/howto/cgi.html|Apache官方DOC-CGI]] * [[http://www.twbsd.org/cht/book/ch13.htm|網頁伺服器]] * [[http://linux.vbird.org/linux_server/0360apache.php#www_adv_cgi|鳥哥-CGI]]