Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a cgi script that opens a file (using python).

The cgi script runs fine but when I try to open this file, I get a permission error:

Traceback (most recent call last):   File "/asdf/pkgs/linux/intel/apache/2.2.14.rhas5.x86_64/htdocs/Sites/cgi-bin/", line 304, in <module>
    main()   File "/asdf/pkgs/linux/intel/apache/2.2.14.rhas5.x86_64/htdocs/Sites/cgi-bin/", line 61, in main
    f=open('/asdf/home/asdf/PYTHON/PERFRPTCRONJOB/TEST_FILES/testfile','r') PermissionError: [Errno 13] Permission denied: '/asdf/home/asdf/PYTHON/PERFRPTCRONJOB/TEST_FILES/testfile'

I've added the folder containing /asdf/home/asdf/PYTHON/PERFRPTCRONJOB/TEST_FILES/testfile to my httpd.conf.

<Directory "/asdf/home/asdf/PYTHON/PERFRPTCRONJOB/TEST_FILES/">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all

I've also changed the permissions of the folder TEST_FILES to 777 and the permissions of testfile to 777. I can open the file via python from the command line but when I try to open this file by running a cgi-script, it fails.

share|improve this question
Never, ever, set the permissions to any file or directory to 777. There are no exceptions. – Dennis Williamson Jun 14 '13 at 4:33
up vote 0 down vote accepted

Check "x" permission for every (sub)directory in the path /asdf/home/asdf/PYTHON/PERFRPTCRONJOB/TEST_FILES/testfile

You can do this with the command:

ls -ld /asdf/home/asdf/PYTHON/PERFRPTCRONJOB/TEST_FILES/testfile /asdf/home/asdf/PYTHON/PERFRPTCRONJOB/TEST_FILES /asdf/home/asdf/PYTHON/PERFRPTCRONJOB /asdf/home/asdf/PYTHON /asdf/home/asdf /asdf/home /asdf
share|improve this answer
It's 777 starting with PERFRPTCRONJOB. I did chmod 777 PERFRPTCRONJOB -R – serverFaulter Jun 14 '13 at 0:51
I've edited my answer. There is an instruction to check all directories in the path, not just some of them – porton Jun 14 '13 at 0:54
Does that matter? I don't want extra permissions for parent directories of PERFRPTCRONJOB. – serverFaulter Jun 14 '13 at 1:00
Every directory in the path should be "executable". Otherwise the file won't open. If you cannot fulfill this requirement, change your directory structure. There is nothing more I can help you: Only you can know which permissions are allowable for which directories – porton Jun 14 '13 at 1:05
Please don't EVER EVER EVER set 777 permissions. It is absolutely never the correct answer. – baumgart Jun 14 '13 at 1:31

Your Answer


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.