CGI does not execute python internal server error - 500

I have some python scripts that I would like to execute, and the following configuration: Ubuntu 10.04, Apache2, Python 2.6, mod_python and mod_wsgi.

I followed the instructions on the following sites:

http://bytes.com/topic/python/answers/474462-apache-python-ubuntu

http://apache.active-venture.com/cgi-configure.html

http://modpython.org/live/current/doc-html/inst-testing.html

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

http://wiki.apache.org/httpd/DistrosDefaultLayout

The default file on accessible sites:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www
    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>

    <Directory /var/www/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride None
            Order allow,deny
            allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
            AddHandler mod_python .py
            AddHandler cgi-script .cgi py
            AllowOverride None
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            Order allow,deny
            Allow from all
    </Directory>

I get an internal server 500 error. I also changed the file permissions to 755

The py files simply print the text to be displayed on the page. What should I do? Thanks

[edit]: , py , .

Traceback (most recent call last):
  File "/usr/lib/cgi-bin/amissa2.py", line 80, in <module>
    zoom_factor = int(parms.getfirst('zoom')) * int(parms.getfirst('zsize'))
TypeError: int() argument must be a string or a number, not 'NoneType'

, None int:

zoom_factor = int(parms.getfirst('zoom')) * int(parms.getfirst('zsize'))

- , ?

+3
2

parms.getfirst('zoom') parms.getfirst('zsize') None, , , URL- (? dunno, , ). , , ( "0" , , , "1" ?).

, , None int ( ) int().

def convert(value):
   if value is None:
      return 0 # or 1, or whatever
   else:
      return int(value)
+1

wsgi.

LoadModule wsgi_module modules/mod_wsgi.so

mod_wsgi mod_python. , .

+1

Source: https://habr.com/ru/post/1783653/


All Articles