Tuesday, June 29, 2010

set up another DocumentRoot other than the default global one

set up another DocumentRoot other than the default global one

一般 vhost 完整的設定 裡面會包含 Directory 的權限設定
沒有的話會是繼承 httpd.conf 裡面的

# vi /etc/httpd-vhosts.conf
### [START] for FTP

  ServerAdmin webmaster@dummy-host2.example.com
  DocumentRoot "/home/ftp/ftp_user0/www"
  ServerName ftp.example.com
  ErrorLog "/var/log/apache/ftp.example.com-error_log"
  CustomLog "/var/log/apache/ftp.example.com-access_log" common

  #php_flag register_globals On

  
    ### Turn off php
    php_admin_flag engine off
    
    Options -ExecCGI

    #AddType text/plain .html .htm .shtml .php

    #Options Indexes FollowSymLinks

    #Options +Indexes FollowSymLinks +ExecCGI
    #AllowOverride AuthConfig FileInfo

    #
    # Controls who can get stuff from this server.
    #
    Order allow,deny
    Allow from all
  

### [END] for FTP

Make sure www user has the read access to the /home/ftp/ftp_user0/www. Please do check following permission of each path

# ls -ld /home

# ls -ld /home/ftp
dr-xr-x--- 6 ftp ftp 512 Jun 29 09:28 /home/ftp

Note: the path above, www user has no access to the /home/ftp directory, so I added www user to the ftp group.

Add www user to the ftp group
# vi /etc/group

Restart Apache
# apachectl stop

# apachectl start

===============

Star:
apache2 預設的話 httpd.conf 裡面應該有一行是 Include etc/apache2/Includes/*.conf

這行的意思跟 php 的 Include 是一樣的
不過他可以用 萬用字元
所以 Include 底下只要是附檔名為 .conf 都會載入

以小築的機器而言 因為是多人共用像我就會在 Include 的目錄底下建一個自己的 vhost.conf 檔 如 myName-vhost.conf
還有 etc/apache2/Includes/*.conf 事實上他的 載入順序是依照 一般英文數字的排序順序載入 如果你 Includes 下有 0.conf 就會比 myName-vhost.conf 還要早載入

No comments: