No problem solved

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.