Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I set up a simple python web server by opening a terminal in a directory and doing

python -m CGIHTTPServer

There is a CGI script in the directory but when I type into the browser

localhost:8000/script.cgi

The CGI script is not executed but is downloaded instead. I chmod'ed the script to 755 but still the same. What am I doing wrong?

share|improve this question

1 Answer 1

From its documentation:

The class will however, run the CGI script, instead of serving it as a file, if it guesses it to be a CGI script. Only directory-based CGI are used — the other common server configuration is to treat special extensions as denoting CGI scripts.

The do_GET() and do_HEAD() functions are modified to run CGI scripts and serve the output, instead of serving files, if the request leads to somewhere below the cgi_directories path. [...]

cgi_directories: This defaults to ['/cgi-bin', '/htbin'] and describes directories to treat as containing CGI scripts.

share|improve this answer

Your Answer

 
discard

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.