[CentOS] Nginx and SELinux on CentOS 7

Wed Jan 1 13:13:22 UTC 2020
Nicolas Kovacs <info at microlinux.fr>

Le 01/01/2020 à 13:54, Benson Muite a écrit :
> Have used Nginx on Fedora with SELinux. Perhaps first try putting your sites in 
> the default document root, /usr/share/nginx/html

After some experimenting, I found the answer.

When I create /var/www manually, ls -Z shows me that it's labled var_t.

But /var/www default context is httpd_sys_content_t, according to matchpathcon.

So a simple restorecon on that directory did the trick:

$ sudo mkdir -v /var/www
mkdir: created directory ‘/var/www’
$ ls -dZ /var/www/
drwxr-xr-x. root root unconfined_u:object_r:var_t:s0 /var/www/
$ matchpathcon /var/www
/var/www system_u:object_r:httpd_sys_content_t:s0
$ sudo restorecon -R -v /var/www/
restorecon reset /var/www context unconfined_u:object_r:var_t:s0
->unconfined_u:object_r:httpd_sys_content_t:s0

Cheers,

Niki

-- 
Microlinux - Solutions informatiques durables
7, place de l'église - 30730 Montpezat
Site : https://www.microlinux.fr
Mail : info at microlinux.fr
Tél. : 04 66 63 10 32
Mob. : 06 51 80 12 12