Results 1 to 8 of 8

Thread: mod_python and apache2 - How do I get it working?

Hybrid View

  1. #1
    Join Date
    Oct 2007
    Location
    Rochester, NY
    Beans
    23
    Distro
    Ubuntu 10.04 Lucid Lynx

    Question mod_python and apache2 - How do I get it working?

    I been googling and searching this forum for about an hour and tried various suggestions and still can't get this working.

    I have Ubuntu 8.04 LTS server.
    I used apt-get install libapache2-mod-python to install it.
    I edited my /etc/apache2.conf CGI directories area (virtual hosting system, btw) as follows:

    Code:
    # CGI Script Configuration
    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory /var/www/public_html/*/>
    #AddHandler cgi-script .cgi
    AddHandler cgi-script .cgi .py
    #AddHandler cgi-script .py
    Options +ExecCGI +Includes
    AddHandler mod_python .py
    PythonHandler mod_python.publisher
    PythonDebug On
    AddType text/html .shtml
    AddHandler server-parsed .shtml
    AddOutputFilter INCLUDES .shtml
    </Directory>
    This is my Python test program:

    Code:
    from mod_python import apache
    
    def handler(req):
      req.content_type = 'text/plain'
      req.write("Hello World!")
      return apache.OK
    In Firefox 3, I get a pop-up window asking me what application I want to open the .py file with.

    In IE 7, it just dumps the source code to test.py without line breaks.

    Can someone please point me in the right direction?

    Thanks...

  2. #2
    Join Date
    Apr 2006
    Location
    Atlanta, USA
    Beans
    427

    Re: mod_python and apache2 - How do I get it working?

    Hi,

    Did you enable the module? If not, you'll need to do that and then restart apache.

    Code:
    sudo a2enmod python
    sudo /etc/init.d/apache2 force-reload
    Here we are, trapped in the amber of the moment. There is no why.

  3. #3
    Join Date
    Oct 2007
    Location
    Rochester, NY
    Beans
    23
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: mod_python and apache2 - How do I get it working?

    Yes, I did that and it said that the module is already installed. I've also restarted using the /etc/init.d/apache2 force-reload and after that, just to be extra sure I did an /etc/init.d/apache2 restart.

    I seem to not be able to get it to work.

  4. #4
    Join Date
    Jul 2008
    Beans
    1

    Re: mod_python and apache2 - How do I get it working?


  5. #5
    Join Date
    Oct 2007
    Location
    Rochester, NY
    Beans
    23
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: mod_python and apache2 - How do I get it working?

    I did that, followed the instructions exactly and Firefox 3 still wants to download the test.py file while IE 7 just prints the source code without line feeds.

    It still won't work.

    Furthermore, if I do the psp route, I get a 403 Forbidden error instead of anything else.

    I've even tried to make the test files executable with no different results.
    Last edited by TCarr; April 22nd, 2009 at 08:24 PM. Reason: Added more info.

  6. #6
    Join Date
    Oct 2007
    Location
    Rochester, NY
    Beans
    23
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: mod_python and apache2 - How do I get it working?

    I just took a look at /var/log/apache2/access.log and /var/log/apache2/error.log and no log entries were made from trying these files.

  7. #7
    Join Date
    Oct 2007
    Location
    Rochester, NY
    Beans
    23
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: mod_python and apache2 - How do I get it working?

    Got it working. Instead of putting the AddHandler and other Python references in /etc/apache2/apache2.conf, I put them in /etc/apache2/sites-enabled/000-default and it works fine.

    Thank you for the link. I led me to the answer, eventually.

  8. #8
    Join Date
    Jun 2009
    Beans
    4

    Re: mod_python and apache2 - How do I get it working?

    I am trying to get this to work as well. I have looked at every single tutorial I can find and none of them work.

    I install both apache2 and libapache2-mod-python through apt-get. And I follow the instructions on modifying the default. Restart apache and I get this:

    apache2: Syntax error on line 185 of /etc/apache2/apache2.conf: Could not open configuration file /etc/apache2/mods-enabled/mod_python.load: No such file or directory

    Apparently mod_python.load is nowhere to be found! I made sure to install libapache2-mod-python so that should mean that all the files should be in there. but they're not! What's going on?

    Where can I download this mod_python.load file or make it myself?

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •