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?
-
1You might like to use something like mod_wsgi to run your python app over a wsgi interface, rather than using CGI.Marcin– Marcin2012年04月13日 08:41:24 +00:00Commented Apr 13, 2012 at 8:41
1 Answer 1
- What is the name of your Python program? Is it
/usr/lib/cgi-bin/file.cgi? - What are the rights of this file? Can it be read by apache? Can it be executed?
- Is first line with
#!/usr/bin/env pythonor similar good? Make sure that this file can be run from command line (ie. shebang is good) - Does apache receive request with that file? Look at apache logs, especially
error.logandaccess.log(probably in/var/log/apache) - Make sure you have enabled
ExecCGIfor/usr/lib/cgi-bin/directory in Apache configuration. For examples see at: http://opensuse.swerdna.org/suseapache.html. You can also useScriptAliasdirective.
answered Apr 13, 2012 at 4:53
Michał Niklas
54.6k19 gold badges77 silver badges125 bronze badges
Sign up to request clarification or add additional context in comments.
10 Comments
madzie
Yes, my filename is file.cgi and the rights are read and write. The first line is #!/usr/bin/env python
Michał Niklas
Does apache receive request with that file? Look at apache logs, especially
error.log and access.log (probably in /var/log/apache)madzie
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".
Michał Niklas
Check where you python interpreter is with
which python commandmadzie
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
|
lang-py