设为首页 收藏本站
查看: 1030|回复: 0

[经验分享] Apache服务器vhost常见配置

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2014-4-11 23:41:40 | 显示全部楼层 |阅读模式
本文涵盖了Apache服务器中常用的vhost配置方法,由于时间关系不在文中进行讲解,仅供参考。
#   
# Virtual Hosts   
#   
# If you want to maintain multiple domains/hostnames on your   
# machine you can setup VirtualHost containers for them. Most configurations   
# use only name-based virtual hosts so the server doesn't need to worry about   
# IP addresses. This is indicated by the asterisks in the directives below.   
#   
# Please see the documentation at   
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before you try to setup virtual hosts.   
#   
# You may use the command line option '-S' to verify your virtual host   
# configuration.   
#   
# Use name-based virtual hosting.   
#   
NameVirtualHost *:80   
#   
# VirtualHost example:   
# Almost any Apache directive may go into a VirtualHost container.   
# The first VirtualHost section is used for all requests that do not   
# match a ServerName or ServerAlias in any <VirtualHost> block.   
#   
<VirtualHost *:80>   
   ServerAdmin dgdenterprise@gmail.com
   DocumentRoot "C:/WANMP/apps/web1.vtest.org"   
   ServerName web1.vtest.org   
#   ServerAlias web1.vtest.org   
   <Directory "C:/WANMP/apps/web1.vtest.org">   
       Options Indexes   
       Order allow,deny   
       IndexOptions Name Charset=UTF-8   
       Allow from all   
   </Directory>   
   ErrorLog "logs/web1.vtest.org-error.log"   
   CustomLog "logs/web1.vtest.org-access.log" common   
</VirtualHost>   
<VirtualHost *:80>   
   ServerAdmin dgdenterprise@gmail.com
   DocumentRoot "C:/WANMP/apps/web2.vtest.org"   
   ServerName web2.vtest.org   
   ErrorLog "logs/web2.vtest.org-error.log"   
   CustomLog "logs/web2.vtest.org-access.log" common   
</VirtualHost>   
<VirtualHost *:80>   
   ServerAdmin dgdenterprise@gmail.com
   DocumentRoot "C:/WANMP/apps/bbs.vtest.org"   
   ServerName bbs.vtest.org   
   ErrorLog "logs/bbs.vtest.org-error.log"   
   CustomLog "logs/bbs.vtest.org-access.log" common   
   <Directory C:\WANMP\apps\bbs.vtest.org/ >   
       Options FollowSymLinks   
       AllowOverride All   
       #    Order deny,allow   
       #    Deny from all   
       RewriteEngine On   
       RewriteBase /   
       RewriteCond %{QUERY_STRING} ^(.*)$   
       RewriteRule ^topic-(.+)\.html$ portal.php?mod=topic&topic=$1&%1   
       RewriteCond %{QUERY_STRING} ^(.*)$   
       RewriteRule ^article-([0-9]+)-([0-9]+)\.html$ portal.php?mod=view&aid=$1&page=$2&%1   
       RewriteCond %{QUERY_STRING} ^(.*)$   
       RewriteRule ^forum-(\w+)-([0-9]+)\.html$ forum.php?mod=forumdisplay&fid=$1&page=$2&%1   
       RewriteCond %{QUERY_STRING} ^(.*)$   
       RewriteRule ^thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ forum.php?mod=viewthread&tid=$1&extra=page\%3D$3&page=$2&%1   
       RewriteCond %{QUERY_STRING} ^(.*)$   
       RewriteRule ^group-([0-9]+)-([0-9]+)\.html$ forum.php?mod=group&fid=$1&page=$2&%1   
       RewriteCond %{QUERY_STRING} ^(.*)$   
       RewriteRule ^space-(username|uid)-(.+)\.html$ home.php?mod=space&$1=$2&%1   
       RewriteCond %{QUERY_STRING} ^(.*)$   
       RewriteRule ^blog-([0-9]+)-([0-9]+)\.html$ home.php?mod=space&uid=$1&do=blog&id=$2&%1   
       RewriteCond %{QUERY_STRING} ^(.*)$   
       RewriteRule ^archiver/(fid|tid)-([0-9]+)\.html$ archiver/index.php?action=$1&value=$2&%1   
       RewriteCond %{QUERY_STRING} ^(.*)$   
       RewriteRule ^([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+)\.html$ plugin.php?id=$1shy.gif2&%1   
   </Directory>   
</VirtualHost>   
<VirtualHost *:80>   
   ServerAdmin dgdenterprise@gmail.com
   DocumentRoot "C:/WANMP/apps/sns.vtest.org"   
   ServerName sns.vtest.org   
   ErrorLog "logs/sns.vtest.org-error.log"   
   CustomLog "logs/sns.vtest.org-access.log" common   
</VirtualHost>   
<VirtualHost *:80>   
   ServerAdmin dgdenterprise@gmail.com
   DocumentRoot "C:/WANMP/apps/www.vtest.org"   
   ServerName www.vtest.org
   ErrorLog "logs/www.vtest.org-error.log"   
   CustomLog "logs/www.vtest.org-access.log" common   
</VirtualHost>   
<VirtualHost *:80>   
   ServerAdmin dgdenterprise@gmail.com
   DocumentRoot "C:/WANMP/apps/sql.vtest.org"   
   ServerName sql.vtest.org   
   ErrorLog "logs/sql.vtest.org-error.log"   
   CustomLog "logs/sql.vtest.org-access.log" common   
</VirtualHost>   
<VirtualHost *:80>   
   ServerAdmin dgdenterprise@gmail.com
   DocumentRoot "C:/WANMP/apps/dns.vtest.org"   
   ServerName dns.vtest.org   
   ErrorLog "logs/dns.vtest.org-error.log"   
   CustomLog "logs/dns.vtest.org-access.log" common   
</VirtualHost>   
<VirtualHost *:80>   
   ServerAdmin dgdenterprise@gmail.com
   DocumentRoot "C:/WANMP/apps/php.vtest.org"   
   ServerName php.vtest.org   
   ErrorLog "logs/php.vtest.org-error.log"   
   CustomLog "logs/php.vtest.org-access.log" common   
</VirtualHost>   
<VirtualHost *:80>   
   ServerAdmin dgdenterprise@gmail.com
   DocumentRoot "C:/WANMP/apps/tmp.vtest.org"   
   ServerName file.vtest.org   
   ErrorLog "logs/file.vtest.org-error.log"   
   CustomLog "logs/file.vtest.org-access.log" common   
   <Directory "C:/WANMP/apps/tmp.vtest.org">   
       Options Indexes   
       Order allow,deny   
       IndexOptions Name Charset=UTF-8   
       Allow from all   
   </Directory>   
</VirtualHost>   
<VirtualHost *:80>   
   ServerAdmin dgdenterprise@gmail.com
   ServerName proxy.vtest.org   
   ProxyPass / http://172.16.169.52/
   ProxyPassReverse / http://172.16.169.52/
   ErrorLog "logs/proxy.vtest.org-error.log"   
   CustomLog "logs/proxy.vtest.org-access.log" common   
</VirtualHost>   
<VirtualHost *:80>   
   ServerAdmin dgdenterprise@gmail.com
   ServerName main.deploy.elp   
   DocumentRoot "C:/WANMP/apps/main.vtest.org"   
   # LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined   
   LogFormat "%h %l %u %t \"%r\" %>s %b" vhostcommon   
   CustomLog logs/main.deploy.elp-access.log vhostcommon   
   ErrorLog "logs/main.deploy.elp-error.log"   
</VirtualHost>


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-17225-1-1.html 上篇帖子: 编译安装最新版本httpd2.4.9的简单配置解析 下篇帖子: Windows下Apache虚拟目录和虚拟主机的配置 服务器
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表