[Linux] Nginx설치 후 Home Directory의 Owner도 같고 file permission 도 했는데 permission error가 날때

SELinux라는 개념이 RHEL5 부터 들어 왔다고 한다 약자는 Security Enhanced Linux 란다..

별의 별짓을 다 해도 계속 적으로 access dined error가 나왔는데 아래처럼 SELinux의 Mode를

바꿔주면 해결 된다.. 단, 보안은 좀 취약해 지는 약점이 있단다..

그럼.. 해결할 수 있는 방법은?? 일단 더 찾아 봐야 할거 같다..
If you still see permission denied after verifying the permissions of the parent folders, it may be SELinux restricting access.

To check if SELinux is running:

# getenforce

To disable SELinux until next reboot:

# setenforce Permissive

Restart Nginx and see if the problem persists. To allow nginx to serve your www directory (make sure you turn SELinux back on before testing this. i.e, setenforce Enforcing)

# chcon -Rt httpd_sys_content_t /path/to/www

See my answer here for more details

 

==== SELinux 의 상세 설명 ============

1. SELinux의 설정
  SELinux에는 3가지 모드가 있습니다.

  • Enforcing – SELinux를 활성화시키고 SELinux 정책을 시행합니다.
  • Permissive – 정책을 시행하는 대신 경고만 출력합니다.
  • Disabled – SELinux 정책을 로드하지 않습니다. SELinux 정책을 완전히 비활성화시킵니다.

또한 2가지 레벨이 있습니다.

  • Targeted – 대상으로 삼은 프로세스를 보호합니다.
  • Mls – 다중 레벨 보안(Multi Level Security) 보호 상태입니다.

2. SELinux 상태 확인
(1) SELinux가 활성된 상태인지 확인

# getenforce
Disabled

(2) SELinux의 상태 확인

# sestatus
SElinux status : enabled
SELinux mount : /selinux
Current mode : enforcing
Mode from config file : enforcing
Policy version : 21
Policy from config file : targeted

-b 옵션을 사용하면 각종 옵션 현황을 확인할 수 있습니다.

3. SELinux 비활성화시키기
(1) 영구히 SELinux를 비활성화시키는 방법
/etc/selinux/config 파일에서
SELINUX=enforcing

SELINUX=disabled
로 수정합니다.

(2) 일시적으로 SELinux를 비활성화시키는 방법

echo 0 > /selinux/enforce
또는
setenforce 0

4. SELinux 활성화시키기
(1) 영구히 SELinux를 활성화시키는 방법
/etc/selinux/config 파일에서
SELINUX=disabled

SELINUX=enforcing
로 수정합니다.

(2) 일시적으로 SELinux를 활성화시키는 방법

echo 1 > /selinux/enforce
또는
setenforce 1