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

Having a weird problem on a Solaris 10 box. I have a cgi script (perl) which needs to overwrite a file. We do not have suexec running on Apache so the destination directory has full (777) access so that Apache can write to it.

The problem is that the CGI script is able to write a new file to the directory but not overwrite an existing file.

**Directory permissions for file destination:** 

drwxrwxrwx 146 myuser white      32768 Jun  2 20:46 dest-dir

**File Permissions of file that needs to be over written:** 

-rw-r--r--   1 myuser white      0 Jun  2 20:50 cgitestfile

Anyone know a simple solution for resolving this ??

Seems like apache can only overwrite a file if it owns it.

share|improve this question

-rw-r--r-- 1 myuser white 0 Jun 2 20:50 cgitestfile

You only have write permissions on the file for owner (myuser) Is apache running as user myuser? or as apache or or something like that? Perhaps you need to add write access for other?

share|improve this answer
Thanks all. I chose to just re-chmod the file each time when I re-write it either in the perl or cgi script. Simple enough. Thanks ! – user770395 Jun 2 '11 at 22:25

On Solaris 10 the default is for apache to run as User nobody, Group nobody (check /etc/apache/httpd.conf User and Group directives). Given your example apache won't be able to write to the cgitestfile as it has no write access to it.

Change the owner:group of dest-dir and the files you want apache to overwrite to nobody

share|improve this answer

I ran into this due to the "SELinux" configuration. If SELinux is running, you need to explictly enable the ability for Apache to write to files. To use this, you also need to set additional permissions on those directories and files for which you are granting write access.

To determine if SELinux is enabled, execute:


To turn on the SE booleans which enabled cgi to write to files:

sudo setsebool -P allow_httpd_anon_write 1
sudo setsebool -P allow_httpd_sys_script_anon_write 1

Then, finally to set the file/directory "SELinux security context type" to a "system" read/write file/directory (you could also make it a "public" type - Google "chcon" for info), execute this:

sudo chcon -R -t httpd_sys_rw_content_t /some/write/path

(Change /some/write/path to your path.)

share|improve this answer

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.