日期:2014-05-17  浏览次数:21163 次

Apache2 域名配置
配置apache2.2 网站域名

修改httpd.conf文件
(1)
配置访问目录的权限
<Directory "F:/webroot/abc">
    Options None
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>



(2)
域名配置
NameVirtualHost 127.0.0.1
<VirtualHost 127.0.0.1:80>
   DocumentRoot F:/webroot/abc
   ServerName   www.abc.com
   ErrorLog F:/logs/abc/error.log
   CustomLog  F:/logs/abc/access.log
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^abc.com  #访问ab.com跳到www.abc.com 地址重写
    RewriteRule ^(.*)$ http://www.abc.com$1 [R=permanent,L]
</VirtualHost>


(3)
代理配置
启动以下功能模块
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
LoadModule proxy_http_module modules/mod_proxy_http.so

配置二级域名
<VirtualHost 127.0.0.1:80>
    DirectoryIndex index.htm
    ServerName bbs.abc.com
    ProxyRequests Off
    <Proxy *>
      Order deny,allow
      Allow from all
    </Proxy>
    ProxyPass / http://127.0.0.1/bbs/
    ProxyPassReverse / http://127.0.0.1/bbs/
   ErrorLog F:/logs/abc/error.log
   CustomLog  F:/logs/abc/access.log
</VirtualHost>