Skip to content

CHICPRO

  • 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

  • SK 세븐모바일 유심 셀프교체
  • php 배열 연산에서 + 와 array_merge 의 차이
  • pcntl_fork 를 이용한 다중 프로세스 실행
  • 아이폰 단축어를 이용하여 주중 공휴일엔 알람 울리지 않게 하기
  • 구글 캘린더 전체일정 재동기화
  • OpenLiteSpeed 웹서버에 HTTP 인증 적용
  • OpenLiteSpeed 웹어드민 도메인 연결
  • WireGuard를 이용한 VPN 환경 구축
  • Ubuntu 22.04 서버에 OpenLiteSpeed 웹서버 세팅
  • 맥 vim 세팅

Recent Comments

  • 편리 on 업무관리용 그누보드 게시판 스킨
  • 임종섭 on 업무관리용 그누보드 게시판 스킨
  • 캐논 5D 펌웨어 | Dslr 펌웨어 업그레이드 방법 82 개의 베스트 답변 on 캐논 EOS 30D 펌웨어 Ver 1.0.6 , EOS 5D 펌웨어 Ver 1.1.1
  • Top 5 캐논 5D 펌웨어 Top 89 Best Answers on 캐논 EOS 30D 펌웨어 Ver 1.0.6 , EOS 5D 펌웨어 Ver 1.1.1
  • 편리 on 워드프레스 애니메이션 gif 파일을 mp4로 변환하여 출력하기
  • 임팀장 on 워드프레스 애니메이션 gif 파일을 mp4로 변환하여 출력하기
  • 편리 on Notepad++ NppFTP 플러그인 수동 설치
  • paul-j on Notepad++ NppFTP 플러그인 수동 설치
  • YS on Windows 10 iCloud 사진 저장 폴더 변경
  • 편리 on Docker를 이용한 Centos7 + httpd + php 5.4 개발환경 구축

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
© 2025 CHICPRO | Built using WordPress and SuperbThemes