Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 388989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:49:22+00:00 2026-05-12T15:49:22+00:00

Just installed and configured mod_python 3.2.8 on a CentOS 5 (Apache 2.2.3) server with

  • 0

Just installed and configured mod_python 3.2.8 on a CentOS 5 (Apache 2.2.3) server with Python 2.4.3. It is loaded fine by Apache.

I activated the mpinfo test page and it works. So I wrote a simple “Hello World” with the following code:

from mod_python import apache

def handler(req):
    req.content_type = 'text/plain'
    req.write("Hello World!")
    req.flush()
    return apache.OK

It outputs a blank page, with no text and no source. If I consciously create a syntax error I get the error output on the URL, for example (when I put a space before “def”):

Mod_python error: "PythonHandler mod_python.cgihandler"

Traceback (most recent call last):

  File "/usr/lib/python2.4/site-packages/mod_python/apache.py", line 299, in HandlerDispatch
    result = object(req)

  File "/usr/lib/python2.4/site-packages/mod_python/cgihandler.py", line 96, in handler
    imp.load_module(module_name, fd, path, desc)

  File "/var/www/vhosts/localhost/httpdocs/mptest.py", line 3

    def handler(req):

    ^

SyntaxError: invalid syntax

I have spent about five hours browsing different tutorials, faqs and trouble shooting guides but can’t find a description of this exakt issue.

What do you think could be the issue/cause?

EDIT: Here is the Apache configuration for the site…

<Directory />
    Options FollowSymLinks
    AllowOverride None

    AddHandler mod_python .py
    PythonHandler mptest
    PythonDebug On 
</Directory>

EDIT 2: Ah, another thing I forgot to mention is that I intend to use mod_python to write Apache extensions. The application itself is written in PHP but I need to make some security tweeks on the server 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T15:49:23+00:00Added an answer on May 12, 2026 at 3:49 pm

    Don’t use mod_python.

    A common mistake is to take mod_python as “mod_php, but for python” and that is not true. mod_python is more suited to writing apache extensions, not web applications.

    The standartized protocol to use between python web applications and web servers (not only apache) is WSGI. Using it ensures that you can publish your application to any wsgi-compliant webserver (almost all modern web servers are wsgi-compliant)

    On apache, use mod_wsgi instead.

    Your example rewritten using the wsgi standard and mod_wsgi on apache:

    mywebapp.py:

    def application(environ, start_response):
        start_response('200 OK', [('content-type', 'text/plain')])
        return ['Hello World']
    

    Apache configuration:

    WSGIScriptAlias /myapp /usr/local/www/wsgi-scripts/mywebapp.py
    <Directory /usr/local/www/wsgi-scripts>
      Order allow,deny
      Allow from all
    </Directory>
    

    Now just go to http://localhost/myapp and the script will run. Additionally, any access under this root (i.e. http://localhost/myapp/stuff/here) will be handled by this script.

    It’s a good idea to choose a web framework. CherryPy. Pylons. Django. They make things even easier.

    A good website to look at is wsgi.org

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 373k
  • Answers 373k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer It seems like you're overcomplicating things for no reason. ValueAtReturn… May 14, 2026 at 7:37 pm
  • Editorial Team
    Editorial Team added an answer The solution is to handle Qt::EditRole when overriding data(). I… May 14, 2026 at 7:36 pm
  • Editorial Team
    Editorial Team added an answer There is no one answer. A good option is to… May 14, 2026 at 7:36 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.