vi /etc/httpd/conf/httpd.conf
httpd默认首页配制:
DirectoryIndex index.html index.html.var
首页的位置定义:
DocumentRoot "/var/www/html"
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/" <Directory "/var/www/cgi-bin"> AllowOverride None Options +ExecCGI Order allow,deny Allow from all </Directory> ServerName localhost:80 AddHandler cgi-script .cgi .pl .py
[root@monitor cgi-bin]# cat hello.py #!/usr/bin/python # -*- coding: UTF-8 -*- print "Content-type:text/html" print print '<html>' print '<head>' print '<meta charset="utf-8">' print '<title>Hello Word - 我的第一个 CGI 程序!</title>' print '</head>' print '<body>' print '<h2>Hello Word! 我是来自菜鸟教程的第一CGI程序</h2>' print '</body>' print '</html>'
gcc test.c -otest.cgi
[root@monitor cgi-bin]# cat test.c
#include <stdio.h>
int main(void)
{
printf("Content-Type: text/html;charset=gb2312 ");
printf("Hello CGI ");
return 0;
}