apache中多域名使用同一个ip的方法

服务器仅有一个ip ,却需要服务多个域名(实际是多个网站的服务),例如你希望使用同一个台web服务器上同时运行www.example.com与www.example.net。 可在httpd.conf配置文件中(可能位于/etc/httpd/conf或/usr/local/apache/conf目录下),添加以下条目:

Server configuration

# Ensure that Apache listens on port 80 Listen 80 # Listen for virtual host requests on all IP addresses NameVirtualHost *:80 <VirtualHost *:80> DocumentRoot /www/example1 ServerName www.example.com # Other directives here </VirtualHost> <VirtualHost *:80> DocumentRoot /www/example2 ServerName www.example.org # Other directives here </VirtualHost> apache会就用户访问的域名对应配置中的ServerName选择合适的web目录输出html代码。以上设置中第一项即 ServerName www.example.com成为默认选项。若用户访问所指定的域名不符合所有条目时采用默认项,即指向 www.example.com。  apache官方的文档: http://httpd.apache.org/docs/2.2/vhosts/examples.html


本文转自maclean_007 51CTO博客,原文链接:http://blog.51cto.com/maclean/1276800
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值