apache配置文件之虚拟主机配置_apache配置文件

阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6
虚拟主机的配置  

(1)基于IP地址的虚拟主机配置  

Listen 80  

<VirtualHost 172.20.30.40>  

DocumentRoot /www/example1  

ServerName www.example1.com  

</VirtualHost>  

<VirtualHost 172.20.30.50>  

DocumentRoot /www/example2  

ServerName www.example2.org  

</VirtualHost>  



(2) 基于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  


<VirtualHost 172.20.30.40:80>  

DocumentRoot /www/example1-80  

ServerName www.example1.com  

</VirtualHost>  


<VirtualHost 172.20.30.40:8080>  

DocumentRoot /www/example1-8080  

ServerName www.example1.com  

</VirtualHost>  


<VirtualHost 172.20.30.50:80>  

DocumentRoot /www/example2-80  

ServerName www.example1.org  

</VirtualHost>  


<VirtualHost 172.20.30.50:8080>  

DocumentRoot /www/example2-8080  

ServerName www.example2.org  

</VirtualHost>  


(3)单个IP地址的服务器上基于域名的虚拟主机配置:  

# 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.example1.com  

ServerAlias example1.com. *.example1.com  

# Other directives here  

</VirtualHost>  


<VirtualHost *:80>  

DocumentRoot /www/example2  

ServerName www.example2.org  

# Other directives here  

</VirtualHost>  


(4)在多个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  


<VirtualHost 172.20.30.50>  

DocumentRoot /www/example1  

ServerName www.example1.com  

# Other directives here ...  

</VirtualHost>  


<VirtualHost 172.20.30.50>  

DocumentRoot /www/example2  

ServerName www.example2.org  

# Other directives here ...  

</VirtualHost>  


(5)在不同的端口上运行不同的站点(基于多端口的服务器上配置基于域名的虚拟主机):  

Listen 80  

Listen 8080  


NameVirtualHost 172.20.30.40:80  

NameVirtualHost 172.20.30.40:8080  


<VirtualHost 172.20.30.40:80>  

ServerName www.example1.com  

DocumentRoot /www/domain-80  

</VirtualHost>  


<VirtualHost 172.20.30.40:8080>  

ServerName www.example1.com  

DocumentRoot /www/domain-8080  

</VirtualHost>  


<VirtualHost 172.20.30.40:80>  

ServerName www.example2.org  

DocumentRoot /www/otherdomain-80  

</VirtualHost>  


<VirtualHost 172.20.30.40:8080>  

ServerName www.example2.org  

DocumentRoot /www/otherdomain-8080  

</VirtualHost>  


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

Listen 80  


NameVirtualHost 172.20.30.40  


<VirtualHost 172.20.30.40>  

DocumentRoot /www/example1  

ServerName www.example1.com  

</VirtualHost>  


<VirtualHost 172.20.30.40>  

DocumentRoot /www/example2  

ServerName www.example2.org  

</VirtualHost>  


<VirtualHost 172.20.30.40>  

DocumentRoot /www/example3  

ServerName www.example3.net  

</VirtualHost>
阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6

“apache配置文件之虚拟主机配置_apache配置文件” 的相关文章

thinkphp3.2怎么使用立即跳转功能 - 编程语言

本篇内容主要讲解“thinkphp3.2怎么使用立即跳转功能”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“thinkphp3.2怎么使用立即跳转功能”吧! 在ThinkPHP框架中,立即跳转功能...

Java Spring之XML的AOP怎么配置 - 开发技术

本篇内容主要讲解“Java Spring之XML的AOP怎么配置”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“Java Spring之XML的AOP怎么配置”吧!1 环境搭建示例:在学习 spring 的 aop 时,采用...

PHP怎么实现表单数据修改 - 编程语言

这篇文章主要介绍“PHP怎么实现表单数据修改”,在日常操作中,相信很多人在PHP怎么实现表单数据修改问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”PHP怎么实现表单数据修改”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!...

背景知识

80386处理器有3种工作模式:实模式,保护模式和虚拟86模式。实模式和虚拟86模式是为了和8086处理器兼容而设计的。在实模式下,80386处理器就相当于一个快速的8086处理器。保护模式是80386处理器的主要工作模式。 实模式:被复位或加电的时候以实模...

PHP更新数据库失败的原因是什么及怎么解决 - 编程语言

这篇“PHP更新数据库失败的原因是什么及怎么解决”文章的知识点大部分人都不太理解,所以小编给大家总结了以下内容,内容详细,步骤清晰,具有一定的借鉴价值,希望大家阅读完这篇文章能有所收获,下面我们一起来看看这篇“PHP更新数据库失败的原因是什么及怎么解决”文章吧。...

怎么搭建php网站并实现局域网访问 - 编程语言

本篇内容主要讲解“怎么搭建php网站并实现局域网访问”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“怎么搭建php网站并实现局域网访问”吧! 一、搭建PHP环境首先,搭建PHP网站需要环境支持,即...