리눅스 [httpd] Apache 웹서버 SELinux 제한 풀기
디렉토리에 쓰기권한을 주었음에도 아파치 웹서버가 디렉토리에 쓰기를 못하는 경우가 있습니다. SELinux 보안 정책에 의해서 apache 웹서버는 쓰기 기능이 막혀있기 때문입니다. 우선 SELinux가 활성화 되어 있는지 확인합니다.
$ getenforce
Enforcing
위 그림처럼 활성화가 되어 있다면 SELinux 설정이 필요합니다. 아파치 웹서버에 대한 보안 정책만 비활성화하면 되지만, 일반적으로 아래와 같이 SELinux 자체를 비활성화 해버리는 경우가 많습니다.
# vim /etc/sysconfig/selinux
아래에서 SELINUX 옵션을 disabled로 바꿉니다.
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
위 설정은 재부팅시 적용됩니다. 따라서 재부팅을 하지 않고 실시간으로 적용하기 위해서 아래와 같이 입력합니다.
# setenforce 0
지금까지는 SELinux 자체를 꺼버리는 방법이었습니다. 하지만 아파치 웹서버에 대한 SELinux 제한을 푸는 방법이 있습니다. 아래와 같이 입력합니다.
# semanage permissive -a httpd_t
이제 파일 쓰기가 가능해졌습니다.
