Skip to content

NCUBE.NET

  • Life Log
  • Cycling Log
  • Photo Log
    • Portrait
    • Landscape
    • Flower
    • Etc
  • Coding Log
  • Information

CentOS 7에서 Apache SELinux 설정

2021-02-09 by 편리

CentOS 7 + Apache 2.4 구성의 개발환경을 구성하다보니 SELinux 가 역시나 태클을 건다. 보안과 관련된 것이니 해제하는 것은 옳은 방법이 아니고.. 프로젝트 때마다 SELinux 설정을 수동으로 하는 게 제일 좋을 것 같아서 관련 내용을 정리해 놓는다. 설정을 진행하지 않으면 접근 때 403 forbidden 에러가 발생한다.

1. 속성 확인

ls -apZ
drwxr-xr-x. chicpro chicpro unconfined_u:object_r:user_home_dir_t:s0 ./
drwxr-xr-x. root    root    system_u:object_r:home_root_t:s0 ../
-rw-------. chicpro chicpro unconfined_u:object_r:user_home_t:s0 .bash_history
-rw-r--r--. chicpro chicpro unconfined_u:object_r:user_home_t:s0 .bash_logout
-rw-r--r--. chicpro chicpro unconfined_u:object_r:user_home_t:s0 .bash_profile
-rw-r--r--. chicpro chicpro unconfined_u:object_r:user_home_t:s0 .bashrc
drwxrwxr-x. chicpro chicpro unconfined_u:object_r:cache_home_t:s0 .cache/
drwxrwxr-x. chicpro chicpro unconfined_u:object_r:httpd_sys_content_t:s0 cmcore/
drwxrwxr-x. chicpro chicpro unconfined_u:object_r:config_home_t:s0 .config/
-rw-rw-r--. chicpro chicpro unconfined_u:object_r:user_home_t:s0 .gitconfig
drwx------. chicpro chicpro unconfined_u:object_r:ssh_home_t:s0 .ssh/
-rw-------. chicpro chicpro unconfined_u:object_r:user_home_t:s0 .viminfo
drwxrwxr-x. chicpro chicpro unconfined_u:object_r:user_home_t:s0 .vscode-server/
drwxrwxr-x. chicpro chicpro unconfined_u:object_r:httpd_user_content_t:s0 www/

2. 특정 디렉토리에 접근권한 주기

chcon -R -t httpd_sys_content_t /home/chicpro/cmcore

3. 특정 디렉토리에 쓰기 권한 주기

chcon -R -t httpd_sys_rw_content_t /home/chicpro/cmcore/data

4. 사용자 인증

htpasswd -c /home/chicpro/.htpasswd chicpro
AuthType Basic
AuthName "Protected Area"
AuthUserFile "/home/chicpro/.htpasswd"
AuthBasicProvider file
# permit access only john and david
# Require user john david
# permit all granted user
Require valid-user

만약 에러 로그에 AH01620: Could not open password file 라는 내용이 기록된다면 SELinux 추가 설정

chcon -t httpd_sys_content_t /home/chicpro/.htpasswd

Post navigation

Previous Post:

PSR 코딩을위해 VS Code 에 php-cs-fixer 적용

Next Post:

Apache 서버에서 htaccess 파일 여러 개 지정하기

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Recent Posts

  • Apache 서버에서 htaccess 파일 여러 개 지정하기
  • CentOS 7에서 Apache SELinux 설정
  • PSR 코딩을위해 VS Code 에 php-cs-fixer 적용
  • Instagram Basic Display API 연동
  • phpMyAdmin에서 root 로그인이 불가능한 경우 해결법
  • Ubuntu20.04 에서 PHP8 업그레이드
  • KRX asp 서비스를 이용한 주가정보 가져오기
  • OPENDART api를 이용한 공시정보 가져오기
  • clipboard.js를 이용한 클립보드에 텍스트 복사
  • PHP Router 비교

Recent Comments

  • 편리 on [PHP] HTTP와 PHP를 이용한 html5 video 스트리밍 구현
  • Kim on [PHP] HTTP와 PHP를 이용한 html5 video 스트리밍 구현
  • 편리 on 워드프레스 애니메이션 gif 파일을 mp4로 변환하여 출력하기
  • 고맙습니다 on 워드프레스 애니메이션 gif 파일을 mp4로 변환하여 출력하기
  • 편리 on PHPMailer를 이용한 이메일 발송
  • 초보자 on PHPMailer를 이용한 이메일 발송
  • 편리 on PHPMailer를 이용한 이메일 발송
  • 초보자 on PHPMailer를 이용한 이메일 발송
  • 편리 on 워드프레스 굿스플로 알림톡 플러그인 개발
  • 남민기 on 워드프레스 굿스플로 알림톡 플러그인 개발

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
© 2021 NCUBE.NET | Built using WordPress and SuperbThemes