文件 /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. 2018/03/22 每日一个Linux命令 之 grep

    Linux grep命令用于查找文件里符合条件的字符串. -- 最长用 搜索 指令,也常常用于 管道 搜索输出等,应用广泛. 这个命令的参数比较多,这里只介绍一部分比较常用的参数,具体的可以到 htt ...

  2. LoadRunner-循环

    Edit Runtime Settings ,设置循环次数 在Open Parameter List 里设置循环参数,比如用例为删除notice,每执行一次用例id值不同. 把id替换为参数,并在参数 ...

  3. extjs分页

    1.本地分页:设置store的proxy属性为pagingmemoryproxy实例 2.远程分页

  4. [记录]Visual Studio 插件

    NuGet Resharper Viasfora : 着色 ozcode2 : 调试 dbforge  调试 phptools vsdoc man DebugStudio Alpha Producti ...

  5. FineReport实现java报表权限使用的效果图

    Java报表-多级权限配置说明 Java报表-联合填报 Java报表-模板内容权限控制 Java报表-权限细粒度控制

  6. 001-window版redis安装

    一.参考地址 官方地址:https://redis.io/ windows版本[学习使用]:https://github.com/MicrosoftArchive/redis 二.windows版re ...

  7. [py][mx]django-解决注册用户已存在,激活链接判断

    注册时候,如果用户已存在,则提示错误 激活用户时候,如果激活链接失效,则提示用户. class RegisterView(View): def get(self, request): register ...

  8. 测试人员需要了解的sql知识(提高篇)

    上一篇写了一些基础的sql知识,这里再深挖一些常用的 ------------------------------------------------------------------骄傲的分割线- ...

  9. PAT 1034 Head of a Gang[难][dfs]

    1034 Head of a Gang (30)(30 分) One way that the police finds the head of a gang is to check people's ...

  10. PAT 1021 Deepest Root[并查集、dfs][难]

    1021 Deepest Root (25)(25 分) A graph which is connected and acyclic can be considered a tree. The he ...