DocumentRoot 변경하기

SE Linux의 보안 강화로 인해서 막혀 있는게 한 두가지가 아닌 것 같다.


아파치 웹서버의 저장소 위치를 /var/www/html/  에서 /home/MyID/www/html 로 변경을 하기로 했다. 기존의 알려진 방법에 의하면

# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
# DocumentRoot "/var/www/html"
DocumentRoot "/home/withover/www/html"

이 부분과

# This should be changed to whatever you set DocumentRoot to.
#
# <Directory "/var/www/html">
<Directory "/home/MyID/www/html">

을 변경을 해주면 된다. 하지만 다음과 같은 에러가 발생할 것이다.

[root@localhost html]# service httpd restart
Stopping httpd:                                            [FAILED]
Starting httpd: Syntax error on line 281 of /etc/httpd/conf/httpd.conf:
DocumentRoot must be a directory

이는 SE Linux의 보안 정책으로 인한 것으로 아래와 같은 작업이 필요하다.

[root@localhost html]# chcon -R -t httpd_user_content_t /home/MyID/www/

아파치 서버가 성공적으로 재실행됨을 볼 수 있을 것이다.


그런데...

Forbidden

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


Apache/2.2.8 (Fedora) Server at 165.194.113.200 Port 80

라고 뜨는건 어찌 해결 할 수 있을지... 결국 SELinux를 꺼야 하는것인가?

댓글 쓰기