标签:
log:
[Sat Sep 12 20:11:44.732201 2015] [cgid:error] [pid 28885:tid 140532305745728] (13)Permission denied: AH01241: exec of ‘/home/puma/local/apache/cgi-bin/test.py‘ failed [Sat Sep 12 20:11:44.733075 2015] [cgid:error] [pid 28682:tid 140532110051072] [client 127.0.0.1:48143] End of script output before headers: test.py
环境:ubuntu14.04 , apache ,python2.7.10,mysql
在mysql中创建 test.books表,通过web请求,使用cgi方式运行books.py,books.py通过MySQLdb查询books表,将结果返回(这实际就是django2.0的例子)
把代码改了改
#! /usr/bin/python # -*- coding: UTF-8 -*- import MySQLdb print "Content-Type:text/html\n" print "<html><head><title>Books</title></head>" print "<body>" print "<h1>books</h1>" print "<ul>" connection=MySQLdb.connect(user=‘root‘,db=‘test‘) cursor=connection.cursor() cursor.execute(‘select name from books order by pub_date‘) for row in cursor.fetchall(): print ‘<li>%s</li>‘ %row[0] print "</ul>" print "<body></html>" connection.close()
直接在shell 里面运行 ./book.py 没什么问题;
web 报错,日志见上,不清楚到底什么权限不正确(apahce安装在/home/puma/local/apache下, mysql 标准安装)
标签:
原文地址:http://www.cnblogs.com/Citizen/p/4803580.html