Apache配置基于端口号的虚拟主机 Apache virtual host configuration is based on the port
有可能只有一个ip出口,但却有多个项目,那么就需要基于端口号架设虚拟主机。
Step 1:
检查是否开启 httpd-vhosts.conf
apache/conf/httpd.conf文件
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
如果没有开启,必须在httpd.conf文件中设置;如果开启,则可以在apache/conf/extra/httpd-vhosts.conf文件中设置,当然也还是可以再httpd.conf文件中进行设置,同样有效。
Step 2:
httpd.conf文件 DocumentRoot一定要是要配置成虚拟主机的项目的父级目录,此处的DocumentRoot限制的级别最高,虚拟主机中设置的DocumentRoot目录级别只能等于或低于此处的DocumentRoot目录。
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "D:\htdocs"
<Directory "D:\htdocs">
Step 3:
httpd.conf文件中添加多端口监听。
#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
Listen 80
Listen 81
Listen 82
Step 4:
按照Step1中的规则,添加虚拟主机配置。
<VirtualHost *:80>
DocumentRoot "D:\htdocs\project1\www"
ServerName 127.0.0.1:80
<Directory "D:\htdocs\project1\www">
Options Indexes FollowSymLinks Multiviews
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:81>
DocumentRoot "D:\htdocs\project2"
ServerName 127.0.0.1:81
<Directory "D:\htdocs\project2">
Options Indexes FollowSymLinks Multiviews
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>
Note:
在虚拟主机配置中一定要覆盖80端口的配置,不然则使用httpd.conf中配置的DocumentRoot的目录,那么项目的上级目录则暴露了。
Apache配置基于端口号的虚拟主机 Apache virtual host configuration is based on the port的更多相关文章
- Tomcat的设置4——Tomcat的体系结构与设置基于端口号的虚拟主机
一.Tomcat体系结构 从conf/server.xml可体现Tomcat的体系.一个Server可有多个service,一个service可以有多个连接器connector,每个连接器暴露出不同的 ...
- Nginx的配置文件简介及在Nginx中配置基于不同ip的虚拟主机
Nginx的配置文件简介及在Nginx中配置基于不同ip的虚拟主机: #user nobody; worker_processes 1; #error_log logs/error.log; #err ...
- Nginx虚拟主机(Virtual Host)配置
虚拟主机(Virtual Host)可以在一台服务器上绑定多个域名,架设多个不同的网站,一般在开发机或者要部署多个小网站的服务器上需要配置虚拟主机.nginx的虚拟主机配置其实也挺简单,为了使得配置文 ...
- Apache配置基于IP的虚拟主机 Apache virtual host configuration is based on the IP
Step 1: 检查是否开启 httpd-vhosts.conf apache/conf/httpd.conf文件 # Virtual hosts Include conf/extra/httpd-v ...
- 【Nginx入门系列】第三章 通过端口号区分虚拟主机
1.配置虚拟主机 (1)连接Nginx所在的服务器(我使用的是putty) (2)切换到nginx.conf 配置文件所在的目录,我目录是/usr/local/nginx/conf (3)增加一个虚拟 ...
- Apache Server 添加虚拟主机(Virtual Host )
当前许多虚拟服务器如阿里云的ECS服务器,都提供各式各样的虚拟机,常见的有Linux.Windows等,如果我们使用了Apache Server作为虚拟机的Web服务器,并且我们希望多个web应用程序 ...
- ***阿里云ECS实战配置虚拟主机 + Apache 配置虚拟主机三种方式
阿里云ECS实战配置虚拟主机 买了一台ECS阿里云服务器,性能感觉有点富余,想着可以陪着虚拟主机多一些WWW目录好放一些其他的程序.比如DEMO什么的. 今天研究了下,主要是就是做基于不同域名的虚拟主 ...
- 8.5 Ingress实现基于域名的多虚拟主机、URL转发、及多域名https实现等案例
1.什么是Ingress Ingress 公开了从k8s集群外部到集群内服务的 HTTP 和 HTTPS 路由. 流量路由由 Ingress 资源上定义的规则控制. 可以将 Ingress 配置为服务 ...
- CentOS 6.8 ftp服务安装配置 基于本地用户和虚拟用户
CentOS 6.8 ftp服务安装配置 基于本地用户和虚拟用户 一.安装ftp服务 1.检查是否已经安装 # rpm -qa | grep ftp ftp-0.17-54.el6.x86_64 vs ...
随机推荐
- 在某OC字符串中,搜索指定的某字符串:-rangeOfString:
NSString *originalStr = @"搜索:王者拜仁!"; NSString *subStr = @"搜索:"; // 在originalStr这 ...
- Codeforces Round #342 (Div. 2) A
A. Guest From the Past time limit per test 1 second memory limit per test 256 megabytes input standa ...
- Saddle Point ZOJ - 3955 题意题
Chiaki has an n × m matrix A. Rows are numbered from 1 to n from top to bottom and columns are numbe ...
- G - YYS FZU - 2278 数学期望 (大数)
Yinyangshi is a famous RPG game on mobile phones. Kim enjoys collecting cards in this game. Suppose ...
- C#中static void Main(string[] args)的含义
static:是将main方法声明为静态的. void:说明main方法不会返回任何内容. String[]args:这是用来接收命令行传入的参数,String[]是声明args是可以存储字符串数组. ...
- 链表系列 - [LeetCode] 链表的交错重排L1,Ln,L2,Ln-1 ....
其实一开始并没有想到时间上O(n)的方法,想到了也是空间复杂度是O(n)的(需要用到栈或者递归):链表分两段,用栈记录第一段的遍历过程. 后来经提示想到了,可以将第二段链表逆序.从而不需要额外的辅助空 ...
- spring中使用@Async注解进行异步处理
引言: 在Java应用中,绝大多数情况下都是通过同步的方式来实现交互处理的:但是在处理与第三方系统交互的时候,容易造成响应迟缓的情况,之前大部分都是使用多线程来完成此类任务,其实,在spring 3. ...
- SPOJ 104 HIGH - Highways
HIGH - Highways http://www.spoj.com/problems/HIGH/ In some countries building highways takes a lot o ...
- 【C++对象模型】第三章 Data语义学
1. Data Member 的布局 同一个Access Section(private, public等)中,data member的顺序按照声明顺序排列,但是没有规定需要连续排序.同时编译器可能会 ...
- jquery ajax的知识点
jquery中的ajax方法参数总是记不住,这里记录一下. 1.url: 要求为String类型的参数,(默认为当前页地址)发送请求的地址. 2.type: 要求为String类型的参数,请求方式(p ...