You most likely have something like:

  <Directory /var/www/aj/cgi-bin>
  SetHandler cgi-script
  Options ExecCGI
  </Directory>

Just search for everything where CGI or cgi appears in configuration.

There are other ways of enabling CGI besides above as well.

One recommendation is not use .py extension for WSGI script files, but
.wsgi as the documentation uses. This can avoid problems where .py
extension set up for CGI.

As to using mod_python and mod_wsgi together, it can work. Main issue
is ensuring both uses Python shared library.

Issues explained in:

  http://code.google.com/p/modwsgi/wiki/InstallationIssues

Graham

2009/3/7 aj <[email protected]>:
>
> Hello,
>
> Interesting.  I don't see anything of consequence in the Apache config
> regarding CGI (unless I shouldn't be loading mod_cgi?)
>
> a...@mmdev0:~/www/cgi-bin/foobar$ grep -rn cgi /etc/apache2/*|grep -v
> sites-available
> /etc/apache2/apache2.conf:145:#ErrorDocument 404 "/cgi-bin/
> missing_handler.pl"
> /etc/apache2/apache2.conf:202:DirectoryIndex index.html index.cgi
> index.pl index.php index.xhtml
> /etc/apache2/apache2.conf:339:# To use CGI scripts outside /cgi-bin/:
> /etc/apache2/apache2.conf:341:#AddHandler cgi-script .cgi
> /etc/apache2/mods-available/cgid.conf:2:ScriptSock /var/run/apache2/
> cgisock
> /etc/apache2/mods-available/cgi.load:1:LoadModule cgi_module /usr/lib/
> apache2/modules/mod_cgi.so
> /etc/apache2/mods-available/cgid.load:1:LoadModule cgid_module /usr/
> lib/apache2/modules/mod_cgid.so
> /etc/apache2/mods-enabled/cgi.load:1:LoadModule cgi_module /usr/lib/
> apache2/modules/mod_cgi.so
> /etc/apache2/sites-enabled/000-default:6:    WSGIScriptAlias /foobar /
> var/www/aj/cgi-bin/foobar/baz.py
>
>
> So on your suggestion, I moved the script to a different location:
> mmdev0:/var/www/aj/foobar# ll
> total 4
> -rwxr-xr-x  1 root root 253 Mar  6 16:12 baz.py
>
> Here's the new Apache config:
> a...@mmdev0:~/www/foobar$ cat /etc/apache2/sites-enabled/000-default
> NameVirtualHost *:80
> <VirtualHost *:80>
>    ServerAdmin webmas...@localhost
>    DocumentRoot /var/www/
>
>    #WSGIScriptAlias /foobar /var/www/aj/cgi-bin/foobar/baz.py
>    WSGIScriptAlias /foobar /var/www/aj/foobar/baz.py
>
>    CustomLog /var/log/apache2/access.log combined
>    ErrorLog /var/log/apache2/error.log
>    LogLevel info
>
> </VirtualHost>
>
> And the results in the log:
> [Fri Mar 06 16:15:44 2009] [notice] SIGHUP received.  Attempting to
> restart
> [Fri Mar 06 16:15:45 2009] [warn] mod_wsgi: Compiled for Python/2.4.4.
> [Fri Mar 06 16:15:45 2009] [warn] mod_wsgi: Runtime using Python/
> 2.4.1.
> [Fri Mar 06 16:15:45 2009] [warn] mod_wsgi: Python module path '/usr/
> lib/python24.zip:/usr/lib/python2.4/:/usr/lib/python2.4/plat-linux2:/
> usr/lib/python2.4/lib-tk:/usr/lib/python2.4/lib-dynload'.
> [Fri Mar 06 16:15:45 2009] [notice] Apache/2.0.54 (Debian GNU/Linux)
> PHP/5.2.0-8+etch7~bpo.1 mod_ssl/2.0.54 OpenSSL/0.9.7e mod_wsgi/2.1-
> BRANCH Python/2.4.1 configured -- resuming normal operations
>
> ==> /var/log/apache2/access.log <==
> 10.10.88.182 - - [06/Mar/2009:16:16:04 -0600] "GET /foobar HTTP/1.1"
> 200 12 "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:
> 1.9.0.6) Gecko/2009011913 Firefox/3.0.6"
>
> ==> /var/log/apache2/error.log <==
> [Fri Mar 06 16:16:04 2009] [info] [client 10.10.88.182] mod_wsgi
> (pid=3758, process='', application='mmdev0.onr.chicago.hostway|/
> foobar'): Loading WSGI script '/var/www/aj/foobar/baz.py'.
>
>
> So it works now...but still baffled about the significance of the
> directory being named cgi-bin when there are no other script aliases
> defined?  So I disabled the cgi module, and restarted again (all other
> things equal), and the test script works in it's current spot.  I then
> revert back to the original WSGIScriptAlias and location in cgi-bin,
> reload Apache, and *now* I get prompted to download the .py file.  So
> there's definitely some dependency on "default" settings in mod_cgi.
> Still not satisfied with my findings.
>
> So here's a new configuration I tried:
> NameVirtualHost *:80
> <VirtualHost *:80>
>    ServerAdmin webmas...@localhost
>    DocumentRoot /var/www/
>
>    WSGIScriptAlias /foobar /var/www/aj/cgi-bin/foobar/baz.py
>    #WSGIScriptAlias /foobar /var/www/aj/foobar/baz.py
>
>    <Directory /var/www/aj/cgi-bin/foobar>
>    SetHandler wsgi-script
>    </Directory>
>
>    CustomLog /var/log/apache2/access.log combined
>    ErrorLog /var/log/apache2/error.log
>    LogLevel info
>
> </VirtualHost>
>
> It seems that using the SetHandler directive in conjunction with a
> WSGIScriptAlias permits the use of the cgi-bin directory.  This logs
> the following:
> [Fri Mar 06 16:23:27 2009] [notice] SIGHUP received.  Attempting to
> restart
> [Fri Mar 06 16:23:27 2009] [warn] mod_wsgi: Compiled for Python/2.4.4.
> [Fri Mar 06 16:23:27 2009] [warn] mod_wsgi: Runtime using Python/
> 2.4.1.
> [Fri Mar 06 16:23:27 2009] [warn] mod_wsgi: Python module path '/usr/
> lib/python24.zip:/usr/lib/python2.4/:/usr/lib/python2.4/plat-linux2:/
> usr/lib/python2.4/lib-tk:/usr/lib/python2.4/lib-dynload'.
> [Fri Mar 06 16:23:27 2009] [notice] Apache/2.0.54 (Debian GNU/Linux)
> PHP/5.2.0-8+etch7~bpo.1 mod_ssl/2.0.54 OpenSSL/0.9.7e mod_wsgi/2.1-
> BRANCH Python/2.4.1 configured -- resuming normal operations
>
> ==> /var/log/apache2/access.log <==
> 10.10.88.182 - - [06/Mar/2009:16:23:29 -0600] "GET /foobar HTTP/1.1"
> 200 12 "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:
> 1.9.0.6) Gecko/2009011913 Firefox/3.0.6"
>
> ==> /var/log/apache2/error.log <==
> [Fri Mar 06 16:23:29 2009] [info] [client 10.10.88.182] mod_wsgi
> (pid=28984, process='', application='mmdev0.onr.chicago.hostway|/
> foobar'): Loading WSGI script '/var/www/aj/cgi-bin/foobar/baz.py'.
>
> Fine. Wonder what happens when I re-enable those other two modules?
>
> [Fri Mar 06 16:26:19 2009] [notice] SIGHUP received.  Attempting to
> restart
> [Fri Mar 06 16:26:19 2009] [notice] mod_python: Creating 8 session
> mutexes based on 20 max processes and 0 max threads.
> [Fri Mar 06 16:26:19 2009] [notice] mod_python: using mutex_directory /
> tmp
> [Fri Mar 06 16:26:20 2009] [warn] mod_wsgi: Compiled for Python/2.4.4.
> [Fri Mar 06 16:26:20 2009] [warn] mod_wsgi: Runtime using Python/
> 2.4.1.
> [Fri Mar 06 16:26:20 2009] [warn] mod_wsgi: Python module path '/usr/
> lib/python24.zip:/usr/lib/python2.4/:/usr/lib/python2.4/plat-linux2:/
> usr/lib/python2.4/lib-tk:/usr/lib/python2.4/lib-dynload'.
> [Fri Mar 06 16:26:20 2009] [notice] Apache/2.0.54 (Debian GNU/Linux)
> mod_python/3.3.1 Python/2.4.1 PHP/5.2.0-8+etch7~bpo.1 mod_ssl/2.0.54
> OpenSSL/0.9.7e mod_wsgi/2.1-BRANCH configured -- resuming normal
> operations
>
> ==> /var/log/apache2/access.log <==
> 10.10.88.182 - - [06/Mar/2009:16:26:23 -0600] "GET /foobar HTTP/1.1"
> 200 12 "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:
> 1.9.0.6) Gecko/2009011913 Firefox/3.0.6"
>
> ==> /var/log/apache2/error.log <==
> [Fri Mar 06 16:26:24 2009] [info] [client 10.10.88.182] mod_wsgi
> (pid=12565, process='', application='mmdev0.onr.chicago.hostway|/
> foobar'): Loading WSGI script '/var/www/aj/cgi-bin/foobar/baz.py'.
>
> Still works.  Guess that's the magic formula?
>
> Eventually I will completely migrate off of and disable mod_python but
> for a period of time, I will have to maintain both.  It sounds like
> you've seen issues with this though?  Maybe I'll have to migrate a
> server at a time...rather than a virt host at a time?
>
>
> Thanks,
> -aj
>
>
> On Mar 6, 4:07 pm, Graham Dumpleton <[email protected]>
> wrote:
>> You haven't mentioned about the AddHandler directive.
>>
>> Not that it matters, the actual problem is probably more to do with
>> fact that you stuck the .py file in the CGI bin directory. I didn't
>> catch that before.
>>
>> So, put the .py script in a different directory.
>>
>> That or show me how the cgi-bin directory is configured.
>>
>> In short, you need to stop script being run as CGI script.
>>
>> Graham
>>
>> 2009/3/7 aj <[email protected]>:
>>
>>
>>
>> > Hi Graham,
>>
>> > Thanks for the suggestions.  I disabled mod_python as you recommended
>> > and restarted Apache.  I then found a pesky .htaccess file in a higher
>> > directory that had some mod_python handler directives, so I removed it
>> > too.  Now I'm back to square one:
>>
>> > [Fri Mar 06 16:01:27 2009] [notice] SIGHUP received.  Attempting to
>> > restart
>> > [Fri Mar 06 16:01:28 2009] [warn] mod_wsgi: Compiled for Python/2.4.4.
>> > [Fri Mar 06 16:01:28 2009] [warn] mod_wsgi: Runtime using Python/
>> > 2.4.1.
>> > [Fri Mar 06 16:01:28 2009] [warn] mod_wsgi: Python module path '/usr/
>> > lib/python24.zip:/usr/lib/python2.4/:/usr/lib/python2.4/plat-linux2:/
>> > usr/lib/python2.4/lib-tk:/usr/lib/python2.4/lib-dynload'.
>> > [Fri Mar 06 16:01:28 2009] [notice] Apache/2.0.54 (Debian GNU/Linux)
>> > PHP/5.2.0-8+etch7~bpo.1 mod_ssl/2.0.54 OpenSSL/0.9.7e mod_wsgi/2.1-
>> > BRANCH Python/2.4.1 configured -- resuming normal operations
>>
>> > ==> /var/log/apache2/access.log <==
>> > 10.10.88.182 - - [06/Mar/2009:16:01:55 -0600] "GET /aj/cgi-bin/foobar/
>> > baz.py HTTP/1.1" 500 539 "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1;
>> > en-US; rv:1.9.0.6) Gecko/2009011913 Firefox/3.0.6"
>>
>> > ==> /var/log/apache2/error.log <==
>> > [Fri Mar 06 16:01:55 2009] [error] [client 10.10.88.182] (8)Exec
>> > format error: exec of '/var/www/aj/cgi-bin/foobar/baz.py' failed
>> > [Fri Mar 06 16:01:55 2009] [error] [client 10.10.88.182] Premature end
>> > of script headers: baz.py
>>
>> > Thanks,
>> > -aj
>>
>> > On Mar 6, 3:57 pm, Graham Dumpleton <[email protected]>
>> > wrote:
>> >> First off disable mod_python loading if you do not really need it as
>> >> it can interfere with mod_wsgi and causes crashes in some cases.
>>
>> >> Second, look through your Apache configuration for:
>>
>> >>   AddHandler cgi-script .py
>>
>> >> It looks like CGI is taking precedence and script isn't being handled
>> >> by mod_wsgi.
>>
>> >> Disable that AddHandler line for CGI.
>>
>> >> Graham
>>
>> >> 2009/3/7 aj <[email protected]>:
>>
>> >> > Hello,
>>
>> >> > I am trying to get a simple example to work with mod_wsgi and having
>> >> > issues.  It appears that the WSGIScriptAlias directive is being
>> >> > ignored by Apache on startup.  Here are the specifics:
>>
>> >> > # server configuration
>> >> > cat /etc/apache2/sites-enabled/000-default
>> >> > NameVirtualHost *:80
>> >> > <VirtualHost *:80>
>> >> >    ServerAdmin webmas...@localhost
>> >> >    DocumentRoot /var/www/
>>
>> >> >    WSGIScriptAlias /foobar /var/www/aj/cgi-bin/foobar/baz.py
>>
>> >> >    CustomLog /var/log/apache2/access.log combined
>> >> >    ErrorLog /var/log/apache2/error.log
>> >> >    LogLevel info
>>
>> >> > </VirtualHost>
>>
>> >> > # request, error log
>> >> > [Fri Mar 06 15:39:39 2009] [notice] SIGHUP received.  Attempting to
>> >> > restart
>> >> > [Fri Mar 06 15:39:39 2009] [notice] mod_python: Creating 8 session
>> >> > mutexes based on 20 max processes and 0 max threads.
>> >> > [Fri Mar 06 15:39:39 2009] [notice] mod_python: using mutex_directory /
>> >> > tmp
>> >> > [Fri Mar 06 15:39:40 2009] [warn] mod_wsgi: Compiled for Python/2.4.4.
>> >> > [Fri Mar 06 15:39:40 2009] [warn] mod_wsgi: Runtime using Python/
>> >> > 2.4.1.
>> >> > [Fri Mar 06 15:39:40 2009] [warn] mod_wsgi: Python module path '/usr/
>> >> > lib/python24.zip:/usr/lib/python2.4/:/usr/lib/python2.4/plat-linux2:/
>> >> > usr/lib/python2.4/lib-tk:/usr/lib/python2.4/lib-dynload'.
>> >> > [Fri Mar 06 15:39:40 2009] [notice] Apache/2.0.54 (Debian GNU/Linux)
>> >> > mod_python/3.3.1 Python/2.4.1 PHP/5.2.0-8+etch7~bpo.1 mod_ssl/2.0.54
>> >> > OpenSSL/0.9.7e mod_wsgi/2.1-BRANCH configured -- resuming normal
>> >> > operations
>>
>> >> > ==> /var/log/apache2/access.log <==
>> >> > 10.10.88.182 - - [06/Mar/2009:15:39:44 -0600] "GET /aj/cgi-bin/foobar/
>> >> > baz.py HTTP/1.1" 500 539 "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1;
>> >> > en-US; rv:1.9.0.6) Gecko/2009011913 Firefox/3.0.6"
>>
>> >> > ==> /var/log/apache2/error.log <==
>> >> > [Fri Mar 06 15:39:44 2009] [error] [client 10.10.88.182] (8)Exec
>> >> > format error: exec of '/var/www/aj/cgi-bin/foobar/baz.py' failed
>> >> > [Fri Mar 06 15:39:44 2009] [error] [client 10.10.88.182] Premature end
>> >> > of script headers: baz.py
>>
>> >> > # contents of my test script
>> >> > mmdev0:/var/www/aj/cgi-bin/foobar# cat baz.py
>> >> > def application(environ, start_response):
>> >> >    status = '200 OK'
>> >> >    output = 'Hello World!'
>>
>> >> >    response_headers = [('Content-type', 'text/plain'), ('Content-
>> >> > Length', str(len(output)))]
>> >> >    start_response(status, response_headers)
>>
>> >> >    return [output]
>>
>> >> > # relevant packages
>> >> > mmdev0:/var/www/aj/cgi-bin/foobar# COLUMNS=120 dpkg -l|egrep "(apache2|
>> >> > python|wsgi)"|grep -v none
>> >> > ii  apache2                  2.0.54-5sarge2           next generation,
>> >> > scalable, extendable web server
>> >> > ii  apache2-common           2.0.54-5sarge2           next generation,
>> >> > scalable, extendable web server
>> >> > ii  apache2-mpm-prefork      2.0.54-5sarge2           traditional
>> >> > model for Apache2
>> >> > ii  apache2-threaded-dev     2.0.54-5sarge2           development
>> >> > headers for apache2
>> >> > ii  apache2-utils            2.0.54-5sarge2           utility programs
>> >> > for webservers
>> >> > ii  hw-mod-wsgi              0.1-7                    hostway
>> >> > packaging of mod_wsgi
>> >> > ii  hwcsi-hwm                1.22.7                   Hostway python
>> >> > library modules
>> >> > ii  libapache2-mod-perl2     1.999.21-1               Integration of
>> >> > perl with the Apache2 web server
>> >> > ii  libapache2-mod-php5      5.2.0-8+etch7~bpo.1      server-side,
>> >> > HTML-embedded scripting language (apache 2 module)
>> >> > ii  libapache2-mod-python    3.3.1-1hw1               Apache 2 module
>> >> > that embeds Python within the server
>> >> > ic  libapache2-mod-python2.3 3.1.3-hw3                An Apache 2
>> >> > module that embeds Python 2.3 within the server
>> >> > ii  python                   2.3.5-2                  An interactive
>> >> > high-level object-oriented language (default vers
>> >> > ii  python-gnuplot           1.7-5                    A Python
>> >> > interface to the gnuplot plotting program
>> >> > ii  python-numeric           23.8-1                   Numerical
>> >> > (matrix-oriented) Mathematics for Python
>> >> > ii  python-soappy            0.11.3-1                 SOAP Support for
>> >> > Python (SOAP.py)
>> >> > ii  python2.3                2.3.5-3sarge2hw0         An interactive
>> >> > high-level object-oriented language (version 2.3)
>> >> > ii  python2.3-crypto         2.0+dp1-2                cryptographic
>> >> > algorithms and protocols for Python
>> >> > ii  python2.3-dev            2.3.5-3sarge2hw0         Header files and
>> >> > a static library for Python (v2.3)
>> >> > ii  python2.3-ldap           2.0.4-1                  A LDAP interface
>> >> > module for Python 2.3
>> >> > ii  python2.3-mysqldb        1.2.1c2-1hw1             A Python
>> >> > interface to MySQL
>> >> > ii  python2.3-numeric        23.8-1                   Numerical
>> >> > (matrix-oriented) Mathematics for Python
>> >> > ii  python2.3-omniorb2       2.6-1                    omniORBpy2 -
>> >> > python 2.3
>> >> > ii  python2.3-omniorb2-omg   2.6-1                    omniORBpy2 -
>> >> > python 2.3 CORBA OMG standard files
>> >> > ii  python2.3-pyopenssl      0.6-2                    Python wrapper
>> >> > around the OpenSSL library
>> >> > ii  python2.3-xml            0.8.4-1                  XML tools for
>> >> > Python (2.3.x)
>> >> > ii  python2.4                2.4.1-2sarge1hw1         An interactive
>> >> > high-level object-oriented language (version 2.4)
>> >> > ii  python2.4-dev            2.4.1-2sarge1hw1         Header files and
>> >> > a static library for Python (v2.4)
>> >> > ii  python2.4-ldap           2.0.4                    A LDAP interface
>> >> > module for Python 2.4
>> >> > ii  python2.4-libxml2        2.6.16-7sarge1           Python 2.4
>> >> > bindings for the GNOME XML library
>> >> > ii  python2.4-mysqldb        1.2.1c2-1hw1             A Python
>> >> > interface to MySQL
>> >> > ii  python2.4-omniorb2       2.6-1                    omniORBpy2 -
>> >> > python 2.4
>> >> > ii  python2.4-omniorb2-omg   2.6-1                    omniORBpy2 -
>> >> > python 2.4 CORBA OMG standard files
>> >> > ii  python2.4-pydb2          1.1.2-hw12               IBM DB2 Python
>> >> > wrapper
>> >> > ii  python2.4-pyltxml        1.3                      Python interface
>> >> > for LT XML
>> >> > ii  python2.4-pyopenssl      0.6-2                    Python wrapper
>> >> > around the OpenSSL library
>> >> > ii  python2.4-xml            0.8.4-1                  XML tools for
>> >> > Python (2.4.x)
>>
>> >> > Thanks in advance for help!
>> >> > -aj
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"modwsgi" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/modwsgi?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to