文件 /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. django比较相等或者不相等的模板语法ifequal / ifnotequal

    转自:http://blog.csdn.net/goupper1991/article/details/50768346 ifequal / ifnotequal      在模板语言里比较两个值并且 ...

  2. Subsequence---poj3061(尺取法||二分)

    题目链接:http://poj.org/problem?id=3061 题意:给n个正整数和一个数S,求出总和不小于S的连续子序列的长度的最小值,如果无解输出0: 我们可以用sum[i]表示前i项的和 ...

  3. 001-window版redis安装

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

  4. golang语言调试

    https://software.intel.com/en-us/blogs/2014/05/10/debugging-performance-issues-in-go-programs https: ...

  5. Goroutines vs Threads

    http://tleyden.github.io/blog/2014/10/30/goroutines-vs-threads/ Here are some of the advantages of G ...

  6. CentOS6.5安装RHadoop

    1.首先安装依赖包(各个节点都要安装) [root@Hadoop-NN-01 ~]$ yum install gcc-gfortran #否则报”configure: error: No F77 co ...

  7. Hive错误:Unable to load native-hadoop library for your platform

    WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin- ...

  8. SQL Expression Language Tutorial 学习笔记一

    http://docs.sqlalchemy.org/en/latest/core/tutorial.html Google 翻译了一下 SQLAlchemy Expression Language, ...

  9. java实现Comparable接口和Comparator接口,并重写compareTo方法和compare方法

    原文地址https://segmentfault.com/a/1190000005738975 实体类:java.lang.Comparable(接口) + comareTo(重写方法),业务排序类 ...

  10. JSON—基础

    什么是JSON?(JavaScript Object Notation) 1:一种轻量级的数据交换格式 2:采用独立于语言的文本格式 3:常用于客户端和服务器之间传递数据(以对象的形式传递) JSON ...