[Linux] 아파치 웹서버 사용자별 웹 디렉토리 설정 –

[Linux] 아파치 웹서버 사용자별 웹 디렉토리 설정
– Per-user web directories
■ 환경
○ OSE : CentOS 7 minimal
○ Apache web server : 2.4.6
■ 아파치 웹 서버 설정
○ 사용자별 웹 디렉토리 사용하도록 설정 : vi  /etc/httpd/conf.d/userdir.conf
<IfModule  mod_userdir.c>
    UserDir  disabled  root
    UserDir  public_html
</IfModule>
<Directory “/home/*/public_html”>
    AllowOverride FileInfo AuthConfig Limit Indexes
    Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
    Require method GET POST OPTIONS
</Directory>
     – root에 대해서는 사용자 웹 디렉토리를 사용하지 않도록 해 보안위협을 예방한다.
     – Indexes 옵션을 제거해 외부 접속자가 임의의 파일에 접근하는 것을 예방한다.
○ PHP 페이지를 위해 웹서버 설정파일에 index.php 추가 : vi  /etc/httpd/conf/httpd.conf
<IfModule  dir_module>
    DirectoryIndex  index.html  index.php
</IfModule>
○ SELinux 설정 : 웹서버가 사용자별 웹 디렉토리에 접근할 수 있도록 권한을 설정한다.
    – 상태확인 : getsebool  httpd_enable_homedirs
       — 확인결과 : httpd_enable_homedirs –> off
    – 상태설정 : setsebool -P httpd_enable_homedirs  on
    – 상태확인 : getsebool  httpd_enable_homedirs
       — 확인결과 : httpd_enable_homedirs –> on
○ 아파치 웹서버 재시작
    – systemctl  restart  httpd
■ 사용자별 웹 디렉토리 설정
○ 접근권한 설정
    – mkdir  /home/account/public_html
    – chmod  711  /home/account
    – chmod  755  /home/account/public_html
○ SELinux 설정 : 웹서버가 사용자의 컨텐츠에 대한 접근을 할 수 있도록 설정한다.
    – 설정 : chcon  -R  -t  httpd_user_content_t  /home/account/public_html
    – 확인 : ls  -aldZ  /home/account/public_html
    ※ httpd가 httpd_t type으로 실행되며 httpd_user_content_t (typealias), httpd_sys_content_t type으로 설정된 파일만 접근할 수 있다.

Leave a Reply

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