Extra Form
PHP PHP 7.2

error log

[Wed Oct 24 16:52:07.512333 2018] [negotiation:error] [pid 27193] (13)Permission denied: [client 121.146.51.58:3037] AH00686: cannot read directory for multi: /home/kants/www/, referer: http://kants.kr/index.php
[Wed Oct 24 16:53:36.969910 2018] [negotiation:error] [pid 27191] (13)Permission denied: [client 216.244.66.242:54084] AH00686: cannot read directory for multi: /home/kants/www/
[Wed Oct 24 16:55:14.582679 2018] [negotiation:error] [pid 27200] (13)Permission denied: [client 121.146.51.58:3076] AH00686: cannot read directory for multi: /home/kants/www/
[Wed Oct 24 16:55:14.864690 2018] [negotiation:error] [pid 27200] (13)Permission denied: [client 121.146.51.58:3076] AH00686: cannot read directory for multi: /home/kants/www/, referer: http://kants.kr/index.php

 

http://kants.kr/

- 접속시, 기본 아파치 php 파일이 뜹니다. 

 

 

http://kants.kr/index.php 

Forbidden

You don't have permission to access /index.php on this server.

 

 

에러가 발생하고 있습니다. 

 http.conf파일에서 디렉토리 설정에 문제는 없다고 여겨지는 것이, 지금 개발 서버가 있어서 거기 있는 파일을 그대로 덮어 씌웠습니다. (서버 환경 같음)

 

 

 home 디렉토리 701 apache.ahache 

 home/kants/   755 kants.kants

home/kants/www 777 kants.kants 

 home/kants/www/index.php 777 kants.kants

 

 이렇게 설정되어있습니다. 당연히 755정도로 하다가, 너무 안되서 777로 했는데도 안되네요, 어디를 손봐야 할지 조언좀 부탁드립니다. 

 

 

  • profile
    http.conf 파일 설정 상태

    <Directory "/home/*/www/.htaccess">
    AllowOverride All
    </Directory>

    <Directory /home/*/www>
    Options FollowSymLinks
    AllowOverride All
    Require all granted
    </Directory>
    <Directory /home/xe/www/>
    Options FollowSymLinks
    AllowOverride All
    </Directory>
  • profile

    개발 서버의 권한 설정을 한번 비교해보세요.

    그리고 일반적으로 /home 의 소유자는 보통 root:root 이고
    그 하위 폴더 /home/kant/ 의 경우 소유자를 일반 사용자(또는 상황에 따라 apache 또는 www-data또는 httpd)가 갖도록 해야 정상적인 권한 세팅이라고 생각됩니다.

    그 뒤 /home/kant 자체의 퍼미션은 500 그 하위 폴더들을 755나 707 또는 777로 조정해야 할것 같습니다.

  • profile profile
    /home/kants라면 당연히 kants 계정이 소유해야지요. 그렇지 않다면 /home 아래에 document root를 둘 이유가 없습니다. 쓰기 권한이 필요한 특정 서브폴더의 퍼미션이나 소유권을 변경하는 것은 다른 문제고요.
  • profile profile
    저도 일반적으로는 home 폴더 아래는 당연히 해당 사용자들이 소유권한을 가지고 있어야 한다고 생각합니다. FTP나 쉘 접속등 웹서버 목적외에 접근을 할 때는 권한이 필요하니깐요.

    질문을 보고 웹 서버 권한만 생각했나봅니다. home의 소유자를 웹서버로 변경한 것을 보니 혼자만 서버를 사용한다고 생각해서 /home/kants 폴더도 그냥 웹 서버에게 소유권한을 넘겨줘도 괜찮겠다고 생각했네요.


    간혹, home 폴더 외에 /var 같은 곳에 document root 를 두는 경우 웹서버에 소유권한을 주는 것을 봐서 헷갈렸나봅니다.
  • profile
    자문 자답 합니다.
    # chcon -R -h -t httpd_sys_content_t /home/kantscom
    # chcon -R -h -t httpd_sys_content_t /home/kants

    참고 url
    http://www.happyjung.com/lecture/2481?sca=Linux
    http://blog.engintruder.com/133
  • profile
    files 디렉토리 같이 쓰기가 필요한 곳은 security context를 httpd_sys_rw_content_t 로 설정해야 웹서버가 디스크에 쓰기를 할 수 있어요.
  • profile profile
    좋은조언 감사드립니다.