I have installed apache web server on my Centos 7, and I have enabled mod_ssl
for it. But when I try to change its default document root to a new one (for example /home/user/public_html
), it shows me a 403 Forbidden
page. I think maybe it's because of the permissions on the directory, but I don't know what to do with it and how to change it. What should I do now? Any help is really appreciated.

- 8,811
- 21
- 32
- 47

- 115
- 6
-
Is SELinux enabled? Can you run the command `ausearch -m AVC,USER_AVC,SELINUX_ERR,USER_SELINUX_ERR -ts recent` – Bert Dec 29 '20 at 20:36
1 Answers
Don't put document roots in user home directories. This is unsafe for a variety of reasons, and SELinux by default will not permit the web server to read files in user home directories. Use a directory that SELinux recognizes, such as /srv/www
, create directories under that for each virtual host, and give them appropriate permissions and ACLs for the users that must access the content.
If for some reason you can't follow good practices and must have the web server read content from user home directories, you can set the httpd_read_user_content
boolean.
setsebool -P httpd_read_user_content 1
But note that, again for security, SELinux will never permit writing to user home directories, so web application functions that expect to write content (e.g. user uploads) will not work. Under another directory such as /srv/www
, directories which must be writable can be given the type httpd_sys_rw_content_t
.

- 244,070
- 43
- 506
- 972