CentOS apache startup config file security error

Try checking the permissions on the folder that contains netdisco_apache.conf

You are right Apache should be able to access the file as it has the same permissions, but it might not be able to access the folder it is contained in.

If you don't want to change folder permissions, just move netdisco_apache.conf to the /etc/httpd/conf directory (remember to update the reference to it in the /etc/httpd/conf/httpd.conf file if you do that.)


I placed my new config file in the /etc/httpd/conf directory, and that didn't solve the problem. I then changed the permissions to match httpd.conf and that didn't solve the problem.

Then I learned about the command ls -Z. The output for mine looks like:

-rw-r--r--. root   root system_u:object_r:httpd_config_t:s0 httpd.conf
-rw-r--r--. root root unconfined_u:object_r:user_home_t:s0 httpd-vhosts.conf

Notice the part at the end. That is called the context. I had created it as my user which gave it the unconfined_u part. To fix this I ran:

sudo chcon system_u:object_r:httpd_config_t:s0 httpd-vhosts.conf

This fixed the problem.


This can easily happen if you are editing an apache.conf, then you save and realize you don't have permission to the current file. If you save to desktop, then using an elevated permission, copy the conf back into place. Thanks for the note on this.