Log
[Sat Sep A -: One:44.732201 -] [Cgid:error] [PID28885: Tid140532305745728] ( -) Permission Denied:AH01241:exec of'/home/puma/local/apache/cgi-bin/test.py'Failed[sat Sep A -: One:44.733075 -] [Cgid:error] [PID28682: Tid140532110051072] [Client127.0.0.1:48143] End of script output before headers:test.py
Environment: ubuntu14.04, Apache, Python2.7.10,mysql
Create the Test.books table in MySQL, use the CGI mode to run books.py,books.py through the Web request, and return the results by MYSQLDB Query Books table (this is actually django2.0 example)
Change the code.
#!/usr/bin/python#-*-coding:utf-8-*-ImportMySQLdbPrint "content-type:text/html\n"Print ""Print "<body>"Print ""Print "<ul>"Connection=mysqldb.connect (user='Root', db='Test') Cursor=connection.cursor () cursor.execute ('select name from Books ORDER by Pub_date') forRowinchCursor.fetchall ():Print '<li>%s</li>'%Row[0]Print "</ul>"Print "<body>"connection.close ()
Run directly inside the shell./book.py no problem;
Web error, log on, not clear what permissions are not correct (Apahce installed under/home/puma/local/apache, MySQL standard installation)
No problem solved