Ubuntu 14.02下编译及配置apache2.4(python CGI)

时间:2015-05-11 01:26:02   收藏:0   阅读:186

Ubuntu 14.02下编译及配置apache2.4(python CGI):

# 下载apache2.4源码包
wget http://mirrors.cnnic.cn/apache//httpd/httpd-2.4.12.tar.gz

# 安装apr依赖库
apt-get install libapr1 libaprutil1 libapr1-dev libaprutil1-dev

# 解压并编译安装
tar -xvf httpd-2.4.12.tar.gz
cd httpd-2.4.12
./configure --prefix=/usr/local/apache2
make && make install

配置CGI:

将下列两行的注释去掉:

#LoadModule cgid_module modules/mod_cgid.so
# AddHandler cgi-script .py

/usr/local/apache2/cgi-bin/中添加test.py,内容为:

#!/usr/bin/python              

print "Content-Type: text/html"
print
print

print "Hello World!"

浏览器中打开链接:http://localhost/cgi-bin/test.py可以看到输出Hello World!

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!