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

[经验分享] 04.12.2011-Apache 配置ServerName linux

[复制链接]

尚未签到

发表于 2015-8-3 08:21:38 | 显示全部楼层 |阅读模式
  [1]
  http://www.google.com.hk/search?hl=en&source=hp&q=apache+%E4%BA%8C%E7%BA%A7%E5%9F%9F%E5%90%8D+servername&aq=f&oq=&aqi=
  http://www.google.com.hk/search?q=Apache+++%E9%85%8D%E7%BD%AEServerName++linux&hl=en&safe=active&prmd=ivns&ei=2vajTaTSI4j0vQPXtJCICg&start=30&sa=N
  [2]
  http://www.jzxue.com/fuwuqi/linux/201007/05-4032_2.html
  (5)在不同的端口上运行不同的站点(基于多端口的服务器上配置基于域名的虚拟主机):
Listen 80
Listen 8080
NameVirtualHost 172.20.30.40:80
NameVirtualHost 172.20.30.40:8080

ServerName www.example1.com
DocumentRoot /www/domain-80


ServerName www.example1.com
DocumentRoot /www/domain-8080


ServerName www.example2.org
DocumentRoot /www/otherdomain-80


ServerName www.example2.org
DocumentRoot /www/otherdomain-8080

(6)基于域名和基于IP的混合虚拟主机的配置:
Listen 80
NameVirtualHost 172.20.30.40

DocumentRoot /www/example1
ServerName www.example1.com


DocumentRoot /www/example2
ServerName www.example2.org


DocumentRoot /www/example3
ServerName www.example3.net

  [3]
  http://www.linuxfly.org/post/542/
  [原]Apache中虚拟主机设置泛域名解析   
大 | 中 | 小
linuxing , 12:04 , 网络服务 » 常见服务 , 评论(0) , 引用(0) , 阅读(1760) , Via 本站原创  大 | 中 | 小
    Apache中设置虚拟主机时,ServerName 的设置不支持扩展符,故若需支持泛域名解析,应用ServerAlias 进行配置。
一、原因
通常情况下,虚拟主机中是用ServerName来的设定对应域名的,如下:
引用
# pwd
/etc/httpd/conf/
# cat vhost_domain.conf
# VirtualHost for LinuxFly Test
ServerName mail.linuxfly.org
DocumentRoot /var/www/extsuite/extmail/html/
ScriptAlias /extmail/cgi/       /var/www/extsuite/extmail/cgi/
Alias /extmail                  /var/www/extsuite/extmail/html/
ScriptAlias /extman/cgi/        /var/www/extsuite/extman/cgi/
Alias /extman                   /var/www/extsuite/extman/html/
# Suexec config
SuexecUserGroup vuser vgroup
但很多时候,我们设置的Apache虚拟主机可能会接收多个域名的访问请求。例如,mail.linuxfly.org、smtp.linuxfly.org 等都指向同一个虚拟主机,也就是说,当我们访问上述任一域名时,应看到同样的内容(应用本身有对域名限制的除外)。
这时,就应用ServerAlias 增加别名设定。
二、ServerAlias 的配置
1、支持多域名
例如,让mail.linuxfly.org、smtp.linuxfly.org、pop3.linuxfly.org 都指向同一个虚拟主机,可以写成:
引用
ServerName mail.linuxfly.org
ServerAlias smtp.linuxfly.org pop3.linuxfly.org
ServerName 用于指定首选域名,其他的域名用ServerAlias指定,并用空格区分即可。
2、支持泛域名解析
ServerAlias 可支持扩展符,例如,我们希望 linuxfly.org 下的所有二级子域名都能用同一个虚拟主机解析,可以设成:
引用
ServerName mail.linuxfly.org
ServerAlias *.linuxfly.org

保存配置后,记得重新加载apache 配置文件:
# service httpd reload
  [4]
  http://hi.baidu.com/xingyuanju/blog/item/87f6b85008f832648435246b.html
  the first has precedence, perhaps you need a
2008-10-18 14:39
报错信息1:
Starting httpd: [Fri May 19 11:49:42 2006] [warn] VirtualHost 127.0.0.1:80 overl
aps with VirtualHost 127.0.0.1:80, the first has precedence, perhaps you need a
NameVirtualHost directive
这个说明虚拟主机的NAME没开,NameVirtualHost 就是他没开,如下就可以了
#加上这里就好了~~,之后就可加任意多的virtual host了
NameVirtualHost 192.168.8.37:80
#
# NOTE: NameVirtualHost cannot be used without a port specifier
# (e.g. :80) if mod_ssl is being used, due to the nature of the
# SSL protocol.
#
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#
#
#     ServerAdmin webmaster@dummy-host.example.com
#     DocumentRoot /www/docs/dummy-host.example.com
#     ServerName dummy-host.example.com
#     ErrorLog logs/dummy-host.example.com-error_log
#     CustomLog logs/dummy-host.example.com-access_log common
#/VirtualHost>


     ServerAdmin webmaster@dummy-host.example.com
     DocumentRoot /var/www/html
     ServerName dummy-host.example.com
     ErrorLog logs/dummy-host.example.com-error_log
     CustomLog logs/dummy-host.example.com-access_log common


     ServerAdmin webmaster@dummy-host.example.com
     DocumentRoot /var/www/html
     ServerName XXX.com
     ErrorLog logs/dummy-host.example.com-error_log
     CustomLog logs/dummy-host.example.com-access_log common


Trackback: http://tb.blog.iyunv.com/TrackBack.aspx?PostId=745383
  [5]
  [6]
  [7]

运维网声明 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-93461-1-1.html 上篇帖子: 用python通过apache log 获取百度搜索来源关键词 下篇帖子: Apache-Tomcat-6.0.20 配置虚拟目录
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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