1

I am new to python cgi programming. I have installed apache 2.2 server on linux mint and I have my html form in var/www folder which is being displayed properly. Action to the form is a cgi script that I've put in the folder /usr/lib/cgi-bin. But on submit, it says "The requested URL /usr/lib/cgi-bin/file.cgi as not found on this server." Does anyone know the fix for this?

1
  • 1
    You might like to use something like mod_wsgi to run your python app over a wsgi interface, rather than using CGI. Commented Apr 13, 2012 at 8:41

1 Answer 1

3
  1. What is the name of your Python program? Is it /usr/lib/cgi-bin/file.cgi?
  2. What are the rights of this file? Can it be read by apache? Can it be executed?
  3. Is first line with #!/usr/bin/env python or similar good? Make sure that this file can be run from command line (ie. shebang is good)
  4. Does apache receive request with that file? Look at apache logs, especially error.log and access.log (probably in /var/log/apache)
  5. Make sure you have enabled ExecCGI for /usr/lib/cgi-bin/ directory in Apache configuration. For examples see at: http://opensuse.swerdna.org/suseapache.html. You can also use ScriptAlias directive.
Sign up to request clarification or add additional context in comments.

10 Comments

Yes, my filename is file.cgi and the rights are read and write. The first line is #!/usr/bin/env python
Does apache receive request with that file? Look at apache logs, especially error.log and access.log (probably in /var/log/apache)
Thank you so much! the error log really helped. It was not able to trace the file path. I changed the default cgi directory to /var/www/cgi-bin and put the script there. The file is being executed now. But now it shows an error "/usr/bin/env: python : No such file or directory".
Check where you python interpreter is with which python command
which python gives "/usr/bin/python". In my cgi script, I have changed first line to #!/usr/bin/python and it still shows the same error
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.