Apache CGI Script Can Cannot Overwrite a File in a Directory it has full permissions

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:

sestatus

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

 

Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>