首页 > 其他分享 >apache配置文件之虚拟主机配置

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

时间:2023-05-28 10:38:44浏览次数:41  
标签:www 配置文件 虚拟主机 ServerName example1 example2 DocumentRoot apache 80

虚拟主机的配置  

(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>

标签:www,配置文件,虚拟主机,ServerName,example1,example2,DocumentRoot,apache,80
From: https://blog.51cto.com/u_16131207/6364816

相关文章

  • apache几种工作模式对比
    apache2主要的优势就是对多处理器的支持更好,在编译时同过使用--with-mpm选项来决定apache2的工作模式。如果知道当前的apache2使用什么工作机制,可以通过httpd-l命令列出apache的所有模块,就可以知道其工作方式:prefork:如果httpd-l列出prefork.c,则需要对下面的段进行配置:<IfM......
  • apache2是什么软件
    Apache2是一种开源的、跨平台的Web服务器软件。它是ApacheHTTPServer的第二个主要版本,通常简称为Apache。Apache2是世界上最流行的Web服务器之一,被广泛用于托管网站和提供Web服务。Apache2提供了一个可靠和稳定的基础架构,用于处理HTTP请求和响应。它支持多种操作......
  • .net core 读取配置文件项
    ///<summary>///配置文件服务///</summary>publicclassAppConfigurtaionServices{///<summary>///配置文件对象///</summary>publicstaticIConfigurationConfiguration{get;set;}......
  • org.apache.jasper.JasperException: Unable to compile class for JSP: An error occ
    org.apache.jasper.JasperException:UnabletocompileclassforJSP:Anerroroccurredatline:16inthejspfile:/monday-01.jspSystem.outcannotberesolvedtoatype13:<body>14:<%15:Stringa=request.getParameter("uname");......
  • 超大型纸业品牌“清风”也用上 Apache SeaTunnel 啦!
    我是韩山峰,来自金红叶纸业集团。今天,我将向大家介绍ApacheSeaTunnel在我们金红叶纸业集团中的应用场景,包括我们为何选择ApacheSeaTunnel,以及我们如何基于其提升我们内部的数据开发效率。文|韩山峰编辑整理|曾辉讲师介绍韩山峰金红叶纸业数据分析师01产品选择历程......
  • 一文教会你用Apache SeaTunnel Zeta离线把数据从MySQL同步到StarRocks
    在上一篇文章中,我们介绍了如何下载安装部署SeaTunnelZeta服务(3分钟部署SeaTunnelZeta单节点Standalone模式环境),接下来我们介绍一下SeaTunnel支持的第一个同步场景:离线批量同步。顾名思意,离线批量同步需要用户定义好SeaTunnelJobConfig,选择批处理模式,作业启动后开始同步数据,当......
  • springboot添加多个环境的配置文件
    1,在resources目录下面新建application.properties,application-dev.properties,application-pre.properties,application-prod.properties2,在application.properties只添加一行要激活的环境,其他不用添加spring.profiles.active=dev3,其他属性文件根据需要配置不同的属性......
  • 一份采用单例模式编写,可读取配置文件的代码
    Confaccess.h#ifndef__CONFACCESS_H__#define__CONFACCESS_H__#include<pthread.h>#include<stdlib.h>#include<string>#include<map>classCConfAccess{public:staticCConfAccess*getInstance(){......
  • 如何将日志配置文件放入到Apollo配置中心并支持热更新
    增加监听日志文件(LoggerConfiguration.java)@ServicepublicclassLoggerConfiguration{privatestaticfinalLoggerlogger=LoggerFactory.getLogger(LoggerConfiguration.class);privatestaticfinalStringLOGGER_TAG="logging.level.";@Autowired......
  • Apache深入优化
    拓扑图:推荐步骤:在centos01安装Apache服务,配置Apache服务设置网站主页在centos02配置DNS服务使用bdqn域名在centos01配置Apache优化prefork和worker工作模式配置压力测试验证实验步骤:在centos01上安装apache服务配置网站配置apache服务启动服务查看运行状态修改apache网站根目录设置......