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 Answer
- 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.
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
|