Configure SELinux access so that Apache can access mounted directories

不羁的心 提交于 2019-11-29 02:45:22

Rather than simply provide a link, but not completely rip off the content of that link, here's the run down.

Install policycoreutils-python that contains SEMANAGE, to allow policy to be set up that will allow Apache to read, or read/write area outside of the DocumentRoot.

yum install -y policycoreutils-python

The article also mentioned a trouble shooting package, but my machine could not locate it.

Create policy for read only areas that are a part of your application, outside of the DocumentRoot

semanage fcontext -a -t httpd_sys_content_t "/webapps(/.*)?"

Create policy for logging directories

semanage fcontext -a -t httpd_log_t "/webapps/logs(/.*)?"

Create policy for cache directories

semanage fcontext -a -t httpd_cache_t "/webapps/cache(/.*)?"

Create policy for read/write areas that are outside of the DocumentRoot

semanage fcontext -a -t httpd_sys_rw_content_t "/webapps/app1/public_html/uploads(/.*)?"

Apply the policy with the restorecon command

restorecon -Rv /webapps

Verify policy has been applied

ls -lZ /webapps

That's it in a nutshell. The original article is nicer to read, however.

If you are using CentOS with SELinux Try:

sudo restorecon -r /var/www/html

See more: https://www.centos.org/forums/viewtopic.php?t=6834#p31548

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!