天空小小岛技术网站

标题: 配置Apache虚拟主机 [打印本页]

作者: s.Bo    时间: 2010-5-1 01:12
标题: 配置Apache虚拟主机
配置文件为:/usr/local/apache2/conf/extra/httpd-vhosts.conf
将配置文件中下面一段修改为如下:
<VirtualHost *:80>
  # ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "/www/wwwroot/supesite"
    ServerName www.jxnews.com.cn
    ErrorLog "|/usr/local/cronolog/sbin/cronolog /www/logs/supesite/error.log-%Y%m%d"
    CustomLog "|/usr/local/cronolog/sbin/cronolog /www/logs/supesite/access.log-%Y%m%d" combined
    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteRule ^/([0-9]+)/spacelist(.+)$ /index.php?uid/$1/action/spacelist/type$2 [L]
        RewriteRule ^/([0-9]+)/viewspace(.+)$ /index.php?uid/$1/action/viewspace/itemid$2 [L]
        RewriteRule ^/([0-9]+)/viewbbs(.+)$ /index.php?uid/$1/action/viewbbs/tid$2 [L]
        RewriteRule ^/([0-9]+)/(.*)$ /index.php?uid/$1/$2 [L]
        RewriteRule ^/([0-9]+)$ /index.php?uid/$1 [L]
        RewriteRule ^/action(.+)$ /index.php?action$1 [L]
        RewriteRule ^/category(.+)$ /index.php?action/category/catid$1 [L]
        RewriteRule ^/viewnews(.+)$ /index.php?action/viewnews/itemid$1 [L]
        RewriteRule ^/viewthread(.+)$ /index.php?action/viewthread/tid$1 [L]
        RewriteRule ^/mygroup(.+)$ /index.php?action/mygroup/gid$1 [L]
    </IfModule>
</VirtualHost>

<VirtualHost *:80>
  # ServerAdmin webmaster@dummy-host2.example.com
    DocumentRoot "/www/wwwroot/discuz"
    ServerName bbs.jxnews.com.cn
    ErrorLog "|/usr/local/cronolog/sbin/cronolog /www/logs/discuz/error.log-%Y%m%d"
    CustomLog "|/usr/local/cronolog/sbin/cronolog /www/logs/discuz/access.log-%Y%m%d" combined
    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteRule ^(.*)/archiver/((fid|tid)-[\w\-]+\.html)$ $1/archiver/index.php?$2
        RewriteRule ^(.*)/forum-([0-9]+)-([0-9]+)\.html$ $1/forumdisplay.php?fid=$2&page=$3
        RewriteRule ^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/viewthread.php?tid=$2&extra=page\%3D$4&page=$3
        RewriteRule ^(.*)/space-(username|uid)-(.+)\.html$ $1/space.php?$2=$3
        RewriteRule ^(.*)/tag-(.+)\.html$ $1/tag.php?name=$2
    </IfModule>


<VirtualHost *:80>
  # ServerAdmin webmaster@dummy-host2.example.com
    DocumentRoot "/www/wwwroot/ucenter"
    ServerName uc.jxnews.com.cn
    ErrorLog "|/usr/local/cronolog/sbin/cronolog /www/logs/ucenter/error.log-%Y%m%d"
    CustomLog "|/usr/local/cronolog/sbin/cronolog /www/logs/ucenter/access.log-%Y%m%d" combined
</VirtualHost>

<VirtualHost *:80>
  # ServerAdmin webmaster@dummy-host2.example.com
    DocumentRoot "/att/attachments"
    ServerName att.jxnews.com.cn
</VirtualHost>

说明:
ServerAdmin 参数后为管理员email
DocumentRoot 指的是论坛文件存放的目录
ServerName  是论坛的域名
ErrorLog 是论坛错误日志  通过管道使用cronolog工具将日志切割为每天一个文件
CustomLog 是论坛访问日志 通过管道使用cronolog工具将日志切割为每天一个文件
<IfModule mod_rewrite.c> 和</IfModule> 包含的字段是rewrite部分,实现URL静态化

配置Apache缺省httpd设置
配置文件为:/usr/local/apache2/conf/extra/httpd-default.conf
将配置文件中下面一段:
将KeepAlive On 改为KeepAlive Off

配置完上述内容之后,重新启动Apache:
# /usr/local/apache2/bin/apachectl restart




欢迎光临 天空小小岛技术网站 (http://tkxxd.net/) Powered by Discuz! X3.1