I've got a CGI script written in python (starts with #!/usr/bin/env python) that executes fine on the server. I type in /home/company/server/root/adam/code.cgi and it outputs the right output. I go to www.myserver.com/adam/code.cgi and all I see is the source code of my cgi script output in plain text.

There's got to be some kind of permissions problem but I'm still new to Linux. I did chmod a+rx * on /home/company/server/root and all subfolders, but I can't make /home, /home/company or /home/company/server globally readable/executable because I'm an intern and don't have high enough permissions and I'm not sure the IT guys want to make them publicly visible.

What do I do? I need the CGI script to be accessible from browsers. Other webpages in the same directory are viewable from the browser and come out in perfectly rendered HTML.


CGI scripts are not automatically executed by the web server just because they're marked executable. This is because they can open up security holes — a bad CGI script in combination with OS bugs can be used for system compromise. Or even without that, it may allow writing to anywhere the apache or www user can write.

What you should do is ask your "IT guys" whether you're permitted to run CGI scripts, and where you should put them so that they can run. It may be that they need to be run from a special cgi-bin directory. Or maybe they need to be run from your ~/public_html/, where they may be set to run under your account rather than a server account (like apache). Or maybe you're not allowed to at all. Or, maybe you just have to ask and they'll configure a CGI-execution directory for you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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