---
title: "Apache监听多个端口"
author: "邪神Saber"
date: "2014-05-22T12:28:00Z"
tags: []
slug: "apache"
draft: false
lastmod: "2014-06-30T15:10:09Z"
id: 2086722
url: "https://softblog.iteye.com/blog/2086722"
---

打开Apache的配置文件httpd.conf

在Listen 80 下面添加多个监听端口如

```
Listen 8011
Listen 8088
```

这样就增加了8011和8088端口的监听

然后在最后的位置设置虚拟主机目录

```
NameVirtualHost *:80
<VirtualHost *:80>
ServerName localhost
DocumentRoot “E:/web1″
</VirtualHost>

NameVirtualHost *:8011
<VirtualHost *:8011>
ServerName localhost:8011
DocumentRoot “E:/web2″
</VirtualHost>

NameVirtualHost *:8088
<VirtualHost *:8088>
ServerName localhost:8088
DocumentRoot “E:/web3″
</VirtualHost>
```

像这样，重启Apache服务，即可以用  
localhost  
localhost:8011  
localhost:8088  
访问你不同的网站了