[완료] 아파치 기본 홈 디렉토리 바꾸는 법이 뭔가요?

dominion의 이미지

CentOS 4.4 Server버전에 아파치 2.0.52를 설치했습니다.
홈디렉토리를 /var/www/html에서 /home/html디렉토리로 바꾸기 위해서 DocumentRoot설정만 바꾸었습니다.
이렇게요

DocumentRoot "/home/html"

그런데 제가 올린 index.html파일을 읽어오지 못하고 처음 아파치를 설치했을 때의 시작화면만 나옵니다.

그래서 IE에서 http://주소/index.html로 지정하면 403에러가 납니다.

제가 뭘 실수 했나 싶어서 DocumentRoot 설정을 처음으로 바꾸었습니다.
그리고 제가 만든 index.html파일을 올렸습니다.
이번에는 제가 만든 index.html내용이 잘 표시됩니다.

다시 DocumentRoot설정만 바꾸었습니다.
또 제가 올린 index.html파일을 읽어오지 못하고 처음 아파치를 설치했을 때의 시작화면만 나옵니다.

그래서 IE에서 http://주소/index.html로 지정하면 403에러가 납니다.

아파치의 기본 홈디렉토리를 바꾸기 위해서는 다른 바꿔야하는 지시어가 또 있나요?
DocumentRoot 지시어만 바꾸면 되는 것 아닌가요?

물론 DocumentRoot설정을 바꾼 후에는 항상 httpd데몬을 재시작 시켰습니다.
디렉토리와 파일 소유자와 소유그룹, 권한도 똑같이 주었습니다.
그런데도 여전히 안됩니다.
도대체 무엇이 문제일까요?

hanbyeol의 이미지

만약 DocumentRoot이 "/usr/local/www/apache22/data"로 지정되어 있다면 ... 아래처럼 Directory 지시자를 적절하게 설정해야 합니다.

설정에 대해서는 http://httpd.apache.org/docs/2.2/mod/core.html#directory 를 참조하세요.

#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "/usr/local/www/apache22/data">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # <a href="http://httpd.apache.org/docs/2.2/mod/core.html#options
" rel="nofollow">http://httpd.apache.org/docs/2.2/mod/core.html#options
</a>    # for more information.
    #
    Options Indexes FollowSymLinks
 
    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride None
 
    #
    # Controls who can get stuff from this server.
    #
    Order allow,deny
    Allow from all
 
</Directory>
dominion의 이미지

hanbyeol님 말씀대로 했는데도 안됩니다.
원래 DocumentRoot 인 /var/www/html 설정부분인
에서
"/var/www/html"부분만 /home/html로 바꾸었는데도 여전히 똑같은 에러가 납니다.

refill의 이미지

쓰신 글로만은 모르겠지만..

일단 http.conf에서 "/var/www/html" 이라는 문자열을 검색해서 치환해보시는게 어떨까요.

DocumentRoot 만 바꾸는게 아니라..

http.conf 전체에서 말이죠.

..

바람과 같이

dominion의 이미지

원인은 selinux였습니다.
개인 서버지만 서버는 서버인지라 보안 문제때문에 SELinux를 올린 상태입니다.
위의 글을 올릴 후 selinux를 올린 상태에서는 문제가 생길 수도 있다는 글을 본 기억이 나서 잠시 구글링을 했습니다.
setenforce 명령으로 SELinux의 기능을 잠시 중지(?) 비슷한 상태로 만들 수 있더군요.
그래서 일시 중지 상태로 만들었습니다.
이런 멀쩡히 잘 나옵니다. -_-;;;
이제 SELinux 설정을 알아봐야겠습니다.

dominion의 이미지

분명히 chmod 등으로 권한도 제대로 설정해줬고, DocumentRoot도 제대로 설정해 줬는데도 웹으로 접근하면 403에러가 나는 경우가 있습니다.
이는 SELinux에서 이 디렉토리에 접근못하게 했기 때문입니다.
이럴 경우 해당 디렉토리에 chcon명령으로 접근이 가능하게 해주시면 됩니다.
예를 들어 새로운 홈디렉토리로 /home/www를 쓰시고 싶으시면 콘솔에서 다음과 같이 치시면 됩니다.

chcon -R -t httpd_user_content_t /home/www

아마 사용자 홈디렉토리들도 이런 식으로 풀어줘야 할 듯 합니다.

윤재만의 이미지

setenforce 명령치면 아래처럼 나오는데.ㅠㅠ
[root@easylearn easylearn]# locate setenforce
치면 암것두 안나오구요~~

[root@easylearn easylearn]# setenforce
bash: setenforce: command not found

chcon 명령어도 마찬가지구요~ㅠㅠ

[root@easylearn easylearn]# chcon
bash: chcon: command not found
[root@easylearn easylearn]# locate chcon

아무도 해결한 사람이 없는지 ㅠㅠ 403 에러.ㅠㅠ

해결법점 아시는분 올려주세요~~

윤재만의 이미지

[root@stream www1]# ls -Z
drwxrwxr-x www1 www1 public_html
[root@stream www1]# chcon -R -t httpd_user_content_t public_html
chcon: can't apply partial context to unlabeled file public_html
[root@stream www1]# chcon -R -t httpd_user_content_t /home/www1/public_html
chcon: can't apply partial context to unlabeled file /home/www1/public_html
[root@stream www1]# chcon -R -h root:object_r:httpd_sys_content_t /home/www1/public_html
[root@stream www1]# wget cm.hmaul.com
--10:25:26-- http://cm.hmaul.com/
=> `index.html'
Resolving cm.hmaul.com... 211.239.117.200
Connecting to cm.hmaul.com|211.239.117.200|:80... connected.
HTTP request sent, awaiting response... 403 Forbidden
10:25:26 ERROR 403: Forbidden.

dominion의 이미지

아래주소로 가보세요.
http://centos.pe.kr/owiki/index.php?url=centos&no=11
sulinux관련 글입니다.
저도 여기서 정보를 얻었습니다.

저도 이번에 새로 리눅스에 입문한 초짜라 아는 것이 별로 없습니다.
여기저기 돌아다니며 단편적인 지식을 주워 듣는 중입니다.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.