文件 /usr/local/apache/conf/extra/httpd-vhosts.conf 的内容如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
NameVirtualHost *:80
<virtualhost *:80>
    ServerName www.example.com
    DocumentRoot /var/www
    DirectoryIndex index.html index.php
    <Directory /var/www>
        Options +Includes -Indexes
        AllowOverride All
        Order Deny,Allow
        Allow from All
        php_admin_value open_basedir /var/www:/tmp:/proc
    </Directory>
</virtualhost>
 
Include conf/vhost/*

提示很明显 NameVirtualHost 已经无效(指的是Apache2.4.x版本),所以配置虚拟主机时不需要设置 NameVirtualHost,把上面的 “NameVirtualHost *:80” 删除掉,问题解决!

apache2.2配置多个端口对应多个目录

由于开发的多项目,每个项目又要独立,要用根目录地址。所以这时候我们需要配置多个不同目录的Apache,如果是外部网可能用多个域名,可以虚拟主机的方式配置;但本地的开发环境就一个地址或者就是localhost,那就要配置多个端口来区别不同的目录,一个配置文件可以设置Apache监听多个端口。

下面是显示方法:

打开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

访问你不同的网站了

二,又一个

增加虚拟网站只需在配置httpd.conf里用VirtualHost配置就好了.

 
# *:80表示监听本机所有IP(需要配置有Listen 80),星号匹配所有地址,
# 因此主服务器(httpd.conf里的DocumentRoot和ServerName)将不会处理任何请求.
# 注意,第一个监听80端口VirtualHost将作为default server用于处理找不到匹配的80请求 <VirtualHost *:80>
DocumentRoot "/path/to/default"
ServerName localhost
</VirtualHost> <VirtualHost *:80>
DocumentRoot "/path/to/a.com"
ServerName a.com
</VirtualHost> <VirtualHost *:80>
DocumentRoot "/path/to/b.com"
ServerName b.com
</VirtualHost>

apache2.4配置多个虚拟主机和多站点配置

http://blog.csdn.net/the_victory/article/details/51006167

http://httpd.apache.org/docs/current/vhosts/examples.html

http://blog.csdn.net/weixin_36429334/article/details/54290422

Apache2.4配置(全)

http://blog.csdn.net/u012291157/article/details/46492137

apache2.4配置多个端口对应多个目录

httpd.conf配置另一个端口

Listen 80
Listen 8084 httpd-vhosts.conf里配置如下
# Virtual Hosts
<VirtualHost *:80>
ServerName localhost
DocumentRoot f:/wamp64/www
<Directory "f:/wamp64/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
#
<VirtualHost *:8084>
#设置主机名
ServerName localhost:8084
#设置主机别名,即用该别名也可以访问(前提是域名解析正确)
#ServerAlias k7wan.com
DocumentRoot "D:/Downloads/php/project/pttuicd/www"
<Directory "D:/Downloads/php/project/pttuicd/www">
#用于显示设定“可显示文件列表”(当无可显示网页的时候)
Options FollowSymLinks Indexes
#启用文件夹访问控制的文件.htaccess设置
AllowOverride All
#请求控制
Require all granted
</Directory>

即可访问http://localhost:8084 到pttuicd这个站点

访问http://localhost到默认wamp的www目录F:\wamp64\www


apache2.4配置多个端口对应多个目录的更多相关文章

  1. ubuntu14.04安装 Apache2 并配置https

    一.安装 Apache2 sudo apt-get update sudo apt-get install apache2 安装完apache2,默认根目录在/var/www/html 下,点击其下的 ...

  2. Ubuntu下的apache2的配置过程

    参考apache2的中文文档:http://httpd.apache.org/docs/2.4/ 安装apache2: apt-get install apache2 安装apache2doc文档:a ...

  3. Ubuntu下apache2安装配置(内含数字证书配置)

    Ubuntu下apache2安装配置(内含数字证书配置)安装命令:sudo apt-get updatesudo apt-get install apache2 配置1.查看apache2安装目录命令 ...

  4. Tomcat配置多个端口号或多个应用

    一.在Tomcat下配置一个应用服务(service)中,配置多个端口号. 即一个service配置多个端口,项目可以通过多个端口访问. 修改tomcat-home\conf下的server.xml, ...

  5. Tomcat中配置多个端口

    在tomcat的conf/server.xml中,配置多个端口,如下: <?xml version="1.0"?> <!--应用1,端口port="80 ...

  6. ubuntu 启用apache2 虚拟机配置

    Ubuntu 启用apache2 虚拟机配置 http://jingyan.baidu.com/article/5d6edee20b78e999eadeecf7.html

  7. Tomcat配置远程调试端口

    Tomcat配置远程调试端口 1.Linxu系统: apach/bin/startup.sh开始处中增加如下内容: declare -x CATALINA_OPTS="-server -Xd ...

  8. tomact配置域名和端口直接访问网站

    tomact配置域名和端口直接访问网站,就是使用域名解析到主机,通过端口执行网站地址,实现访问,在上一章节中发布了两个web项目,但是都是执行同一个根文件夹,通过 http://localhost:8 ...

  9. linux apache虚拟主机配置(基于ip,端口,域名)

    配置环境: linux版本:Centos6.4 httpd版本: [root@centos64Study init.d]# pwd/etc/init.d[root@centos64Study init ...

随机推荐

  1. 图论——最小生成树prim+邻接表+堆优化

    今天学长对比了最小生成树最快速的求法不管是稠密图还是稀疏图,prim+邻接表+堆优化都能得到一个很不错的速度,所以参考学长的代码打出了下列代码,make_pair还不是很会,大体理解的意思是可以同时绑 ...

  2. GET、POST编码问题

    GET请求.POST经常会出现中文乱码的问题,最好约定前后端的编码,一般为UTF-8.但是这里面也是有坑的. 后端设置编码为UTF-8的推荐方式: SpringMVC配置过滤器: <filter ...

  3. javaScript高级教程(三) javaScript不支持关联数组,只是语法上像关联数组

    1.在js中所有要素都是继承自Object对象的,任何对象都能通过obj['name'] = something的形式来添加属性,相当于obj.name=something. 之所以设计中括号这种存取 ...

  4. 003-spring cloud gateway-概述、Route模型、网关初始化配置过程、基本原理

    一.概述 网关服务核心是将进入的请求正确合理的路由到下层具体的服务进行业务处理,由此可见网关服务的核心就是路由信息的构建. Spring Cloud Gateway旨在提供一种简单而有效的方式来路由到 ...

  5. 分享一个自定义的 console 类,让你不再纠结JS中的调试代码的兼容

    问题的产生 在写JS的过程中,为了调试我们常常会写很多 console.log.console.info.console.group.console.warn.console.error代码来查看JS ...

  6. PHP消息队列实现及应用_慕课网学习

    https://blog.csdn.net/d_g_h/article/details/79643714 https://blog.csdn.net/tTU1EvLDeLFq5btqiK/articl ...

  7. Spark中cache和persist的区别

    cache和persist都是用于将一个RDD进行缓存的,这样在之后使用的过程中就不需要重新计算了,可以大大节省程序运行时间. cache和persist的区别 基于Spark 1.6.1 的源码,可 ...

  8. 手工利用Chrome浏览器“Javascript控制台”

    1.打开Chrome浏览器,输入网址:http://forum.csdn.net/SList/HTMLCSS/ 2.按下“Ctrl+Shift+J”打开“Javascript控制台”工具 3.动态引用 ...

  9. 修改class文件

    http://yucaifu1989.iteye.com/blog/1850500 http://blog.csdn.net/hexin373/article/details/6669813 使用ja ...

  10. sklearn总览