Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using turnkey image for python 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

share|improve this question

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

share|improve this answer
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 '10 at 3:32

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.

share|improve this answer

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 

Then you need to do:

VirtualHost Config:

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

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

share|improve this answer
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 '10 at 6:57

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.