Apache虚拟主机的配置和泛域名解析实现代码_Linux

虚拟主机的配置
  基于IP地址的虚拟主机配置
  Listen 80
  DocumentRoot /www/jb51
  ServerName www.jb51.net
  DocumentRoot /www/jb512
  ServerName www.jb512.org
  基于IP和多端口的虚拟主机配置
  Listen 172.20.30.40:80
  Listen 172.20.30.40:8080
  Listen 172.20.30.50:80
  Listen 172.20.30.50:8080
  DocumentRoot /www/jb51-80
  ServerName www.jb51.net
  DocumentRoot /www/jb51-8080
  ServerName www.jb51.net
  DocumentRoot /www/example2-80
  ServerName www.jb51.org
  DocumentRoot /www/example2-8080
  ServerName www.example2.org
  单个IP地址的服务器上基于域名的虚拟主机配置:
  # Ensure that Apache listens on port 80
  Listen 80
  # Listen for virtual host requests on all IP addresses
  NameVirtualHost *:80
  DocumentRoot /www/jb51
  ServerName www.jb51.net
  ServerAlias jb51.net. *.jb51.net
  # Other directives here
  DocumentRoot /www/example2
  ServerName www.example2.org
  # Other directives here
  在多个IP地址的服务器上配置基于域名的虚拟主机:
  Listen 80
  # This is the “main” server running on 172.20.30.40
  ServerName server.domain.com
  DocumentRoot /www/mainserver
  # This is the other address
  NameVirtualHost 172.20.30.50
  DocumentRoot /www/jb51
  ServerName www.jb51.net
  # Other directives here …
  DocumentRoot /www/example2
  ServerName www.example2.org
  # Other directives here …
  在不同的端口上运行不同的站点:
  基于多端口的服务器上配置基于域名的虚拟主机。
  Listen 80
  Listen 8080
  NameVirtualHost 172.20.30.40:80
  NameVirtualHost 172.20.30.40:8080
  ServerName www.jb51.net
  DocumentRoot /www/domain-80
  ServerName www.jb51.net
  DocumentRoot /www/domain-8080
  ServerName www.example2.org
  DocumentRoot /www/otherdomain-80
  ServerName www.example2.org
  DocumentRoot /www/otherdomain-8080
  基于域名和基于IP的混合虚拟主机的配置:
  Listen 80
  NameVirtualHost 172.20.30.40
  DocumentRoot /www/jb51
  ServerName www.jb51.net
  DocumentRoot /www/example2
  ServerName www.example2.org
  DocumentRoot /www/example3
  ServerName www.example3.net
  网站泛域名解析
  添加一个虚拟主机配置(如下):
  
  DocumentRoot d:/web/jb51 # 网站根目录的绝对路径
  ServerName www.jb51.net # 网站域名
  ServerAlias *.jb51.net # 网站泛域名

APACHE泛域名配置参考

NameVirtualHost 192.168.0.110

<VirtualHost 192.168.0.110:80>
DocumentRoot "E:/InterRoot/workplace/"
ServerName www.workplace.com
<Directory "E:/InterRoot/workplace/">
AllowOverride FileInfo
Options Indexes FollowSymLinks Includes
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

<VirtualHost 192.168.0.110:80>
DocumentRoot "E:/InterRoot/busymouse_test/"
ServerName www.test.com
<Directory "E:/InterRoot/busymouse_test/">
AllowOverride FileInfo
Options Indexes FollowSymLinks Includes
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

<VirtualHost 192.168.0.110:80>
DocumentRoot "E:/InterRoot/iptv_for_browser/auth"
ServerName auth.billing.com
ServerAlias auth.billing.com *.auth.billing.com
#泛域名解析
ErrorLog "E:/InterRoot/iptv_for_browser/serverlog/apache.log"
<Directory "E:/InterRoot/iptv_for_browser/auth">
AllowOverride FileInfo
Options Indexes FollowSymLinks Includes
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

<VirtualHost 192.168.0.110:80>
DocumentRoot "E:/InterRoot/iptv_for_browser/api"
ServerName voiz.billing.com
ErrorLog "E:/InterRoot/iptv_for_browser/serverlog/apache.log"
<Directory "E:/InterRoot/iptv_for_browser/api">
AllowOverride FileInfo
Options Indexes FollowSymLinks Includes
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

<VirtualHost 192.168.0.110:80>
DocumentRoot "E:/InterRoot/iptv_for_browser/user"
ServerName user.billing.com
ErrorLog "E:/InterRoot/iptv_for_browser/serverlog/apache.log"
<Directory "E:/InterRoot/iptv_for_browser/user">
AllowOverride FileInfo
Options Indexes FollowSymLinks Includes
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

<VirtualHost 192.168.0.110:80>
DocumentRoot "E:/InterRoot/iptv_for_browser/center"
ServerName center.billing.com
ErrorLog "E:/InterRoot/iptv_for_browser/serverlog/apache.log"
<Directory "E:/InterRoot/iptv_for_browser/center">
AllowOverride FileInfo
Options Indexes FollowSymLinks Includes
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

<VirtualHost 192.168.0.110:80>
DocumentRoot "E:/InterRoot/iptv_for_browser/img"
ServerName img.billing.com
ErrorLog "E:/InterRoot/iptv_for_browser/serverlog/apache.log"
<Directory "E:/InterRoot/iptv_for_browser/img">
AllowOverride FileInfo
Options Indexes FollowSymLinks Includes
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

<VirtualHost 192.168.0.110:80>
DocumentRoot "E:/InterRoot/iptv_for_browser/log"
ServerName log.billing.com
ErrorLog "E:/InterRoot/iptv_for_browser/serverlog/apache.log"
<Directory "E:/InterRoot/iptv_for_browser/log">
AllowOverride FileInfo
Options Indexes FollowSymLinks Includes
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

<VirtualHost 192.168.0.110:80>
DocumentRoot "E:\InterRoot\billing_new\front"
ServerName admin.billing.com
ErrorLog "E:/InterRoot/iptv_for_browser/serverlog/apache.log"
<Directory "E:\InterRoot\billing_new\front">
AllowOverride FileInfo
Options Indexes FollowSymLinks Includes
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

时间: 2024-08-03 07:10:41

Apache虚拟主机的配置和泛域名解析实现代码_Linux的相关文章

Apache虚拟主机的配置过程

Apache虚拟主机的配置过程有三种:基于Ip.基于端口.基于域名 这是在红帽5.8的系统上做的,首先挂载光盘,配置yum库,安装开发环境 mkdir /mnt/cdrom mount /dev/cdrom /mnt/cdrom vim /etc/yum.reps.d/server.repo [base] name=server baseurl=file:///mnt/cdrom/Server enabled=1 gpgcheck=0 yum groupinstall "Development

apache虚拟主机的配置指南_Linux

一.检查apache虚拟主机模块 apache要配置虚拟主机,就需要先查看apache是否编译vhost_alias_module模块.当然apache默认是已经编译该模块的,我们可以通过以下命令查看是否已经编译模块,如下: /usr/local/apache2/bin/apachectl -M 二.开启apache虚拟主机功能 要开启apache虚拟主机功能,我们需要修改apache配置文件http.conf.打开apache的安装目录,找到httpd.conf文件,去掉Include con

Apache虚拟主机基本配置与高级配置指南

测试环境 操作系统:http://www.aliyun.com/zixun/aggregation/13835.html">Ubuntu 10.04 测试机地址:10.39.6.59 测试机域名:*.firehare.com 基本配置 我们都知道,如果我们想在单台机器上设置多个域名或主机名时,我们就要用到基于名称的虚拟主机了.那么要如何进行设置呢?这就是本指南想解决的问题了.在 Ubuntu 的 /etc/apache2/ 目录下有个 Apache2 的主配置文件 apache2.conf

apache 虚拟主机的配置方法

方法一: 首先打开apache中conf下的http.conf文件打开虚拟主机的注释:如下去掉第二行 前面的#即可 # Virtual hosts # Include conf/extra/httpd-vhosts.conf 再打开conf目录下的extra目录中的httpd-vhosts.conf文件 在文件最后面加上 <VirtualHost *:80>//你的虚拟主机所使用的端口号 ServerAdmin webmaster@dummy-host2.localhost //虚拟主机的管理

apache 虚拟主机的配置方法_Linux

方法一: 首先打开apache中conf下的http.conf文件打开虚拟主机的注释:如下去掉第二行前面的#即可 # Virtual hosts # Include conf/extra/httpd-vhosts.conf 再打开conf目录下的extra目录中的httpd-vhosts.conf文件 在文件最后面加上 <VirtualHost *:80>//你的虚拟主机所使用的端口号 ServerAdmin webmaster@dummy-host2.localhost //虚拟主机的管理员

Apache 虚拟主机的配置

配置虚拟主机的步骤: ① 找到Apache配置文件httpd.conf,让Apache服务器加载配置虚拟主机的文件: #Include conf/extra/httpd-vhosts.conf,将前面的注释去掉 ② 修改本机C:\Windows\System32\drivers\etc\host文件把不同的主机名指向相对应的ip 例如:  ip   域名  127.0.0.1   www.baidu.com ? 在apache/conf/extra/httpd-vhosts.conf的末尾写上:

Apache虚拟主机(vhost)配置例子

先附上官方的examples:apache.org/docs/2.0/vhosts/examples.html">http://httpd.apache.org/docs/2.0/vhosts/examples.html 首先找到Apache的配置文件httpd.conf 确认有下面一行:  代码如下 复制代码 # Virtual hosts Include "conf/extra/httpd-vhosts.conf" 如果没有,请在配置文件末尾添加.然后找到httpd

域名-apache虚拟主机配置无效,直接跳回根目录的原因是什么?

问题描述 apache虚拟主机配置无效,直接跳回根目录的原因是什么? 使用的是apache2.4.9,将httpd-vhost文件里的模板复制一份更改后发现, 域名访问全部跳回网站根目录,这是什么原因? 解决方案 Include "conf/extra/httpd-vhosts.conf" 解决方案二: Apache 虚拟主机 VirtualHost 配置

centos7-CentOS 7 怎样配置apache虚拟主机?

问题描述 CentOS 7 怎样配置apache虚拟主机? 跟ubuntu有点不同,没有看到类似的sites-enable文件夹 解决方案 CentOS下配置apache虚拟主机CentOS Apache虚拟主机配置CentOS中增加apache虚拟主机的配置