Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

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 have a test script, /var/www/etym/cgi-bin/

# -*- coding: UTF-8 -*-

# enable debugging
import cgitb

print "Content-Type: text/plain;charset=utf-8"

print "Hello World!"

And I'm trying to run it by going to http://localhost/etym/cgi-bin/ in my browser, but it's not working--Firefox just asks me whether I'd like to open the file with gedit or save it to the disk. What do I need to do to get it to run? I already ran chmod +x on the script.

share|improve this question
Could you explain what your requirements are? Most people use wsgi for Python nowadays or simply a framework to build the applications in. Do you really need to do it plain CGI or...? And what web server are you using? (You probably don't want to run one, or you want a wsgi module for you web server.) – gertvdijk Aug 26 '13 at 19:21
I just want to be able to run a simple python script on a web server. I'm just using the standard apache2 that comes with ubuntu and the stock configuration. I don't know the difference between cgi and wsgi, and so I'm not married to CGI, but I don't want to have to configure a big framework, apache modules, or other complicated things just to be able to see "Hello World" in my browser window. – Jon Aug 26 '13 at 19:33
You can try flask ( for simple python "hello world" web scripts. – pondohva Aug 26 '13 at 20:17
"/var/www/etym/cgi-bin/" please put those files OUTSIDE your webroot. – Rinzwind Apr 29 '14 at 14:59
up vote 1 down vote accepted

Make sure you have configured your webserver properly to run CGI scripts.

Refer this for more info:

share|improve this answer

this could help if the link doesnt yet solve the problem (tried on Ubuntu 14.04)

Check loaded modules with:

   apache2ctl -M

Look for:

  cgid_module (shared)

If it's not loaded, load it with:

  a2enmod cgid    

Restart apache and then refresh browser

share|improve this answer

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.