SELinux: Cannot write into “Config” directory! [OwnCloud]

Updated on March 15, 2022

I installed owncloud with all the necessary pre-requisites and when tried to access over the browser encountered error: Cannot write into "Config" directory! Below is the complete error list.

OwnCloud Error: Cannot write into "Config" directory!

How to fix Cannot write into “Config” directory! [OwnCloud]

The error above clearly conveys that, the webserver is unable to write into the “Config” directory. Checked the file permissions and ownership. All files in the DocumentRoot are owned by apache user and are having the read and write permissions to the files and the directory. This is similar to directory permission denied by SELinux policy, as SELinux is enabled by default on CentOS 7 and later. Below is the SELinux info for the config directory. Notice the highlighted context type, which is a read-only directory!

# ls -lZd /var/www/owncloud/config
drwxrwxrwx. 2 apache apache unconfined_u:object_r:httpd_sys_content_t:s0 79 Mar 15 04:49 /var/www/owncloud/config
Change your OwnCloud Installation directory

Apache Context Types

Below are the Apache context types we are primarily interested in.

httpd_sys_content_tRead-only directories and files used by Apache
httpd_sys_rw_content_tReadable and writable directories and files used by Apache. Assign this to directories where files can be created or modified by your application, or assign it to files directory to allow your application to modify them.

For a complete list of context types for Apache.

Create SELinux Policy for ReadWrite Access

OwnCloud needs read-write access to the config directory. Apart from usual chmod permissions, we need to apply the context which allows webserver to be able to write into the directory. Execute the below command to assign httpd_sys_rw_content_t context to the config directory and all child files.

# semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/owncloud/config/'

# restorecon '/var/www/owncloud/config/'
Change your OwnCloud Installation directory

[OR]

By enabling SELinux httpd_unified & httpd_execmemboolean as below:

# setsebool -P httpd_unified 1

# setsebool -P httpd_execmem 1

For more on SELinux Booleans.

Was this article helpful?

Related Articles

Comments Leave a Comment

Leave a Comment