0

I am using turnkey image for python django http://www.turnkeylinux.org/django

When i open the page by ip adress the home page open ok

Now i tried to made the simple python file inside the wwwroot to check but apache is not executing it. it asks me to download it

THe code of file is

#!/usr/bin/env python

print "Content-Type: text/plain\n\n"
print 'Hello, world!\n' 

Its the pre made vmware image and django is working. How can i check my example

3 Answers 3

0

By default, CGI scripts must be placed in cgi-bin/, must be executable, and must not be world-writable.

1
  • DO you mean i have to create a folder called cgi-bin because currently the default directory of django is /var/www/django-sites/httpdocs . i just want to display hello on web browser. Also then how can i see the django site , i think that is also python and that is not insdie cgi-bin.
    – John
    Jun 23, 2010 at 3:32
0

Django doesn't run as CGI. Grep around /etc/apache2 to see where /var/www/django-sites/apps is configured. The configuration file should be named /etc/apache2/sites-enabled/django or similar, and Django is configured with a WSGIScriptAlias directive.

0

chmod 755 the script

If that doesn't work, try putting the following in .htaccess:

Options +ExecCGI
AddHandler cgi-script .cgi 

If that doesn't work, try putting those in a Directory block in your VirtualHost config and restart apache:

<Directory /path/to/webroot/>
Options +ExecCGI
AddHandler cgi-script .cgi 
</Directory>

Then you need to do:

VirtualHost Config:

<Directory /path/to/webroot/>
Options +ExecCGI
AddHandler wsgi-script .wsgi
</Directory>

test.wsgi def application(environ, start_response): start_response('200 OK',[('Content-type','text/html')]) return ['Hello World!']

1
  • i will try that but one thing worries me is that i want to run python via web using mod_wsgi , why i need to enable cgi-bin for that
    – John
    Jun 23, 2010 at 6:57

You must log in to answer this question.