apache2.4配置多个端口对应多个目录
文件 /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配置多个端口对应多个目录的更多相关文章
- ubuntu14.04安装 Apache2 并配置https
一.安装 Apache2 sudo apt-get update sudo apt-get install apache2 安装完apache2,默认根目录在/var/www/html 下,点击其下的 ...
- Ubuntu下的apache2的配置过程
参考apache2的中文文档:http://httpd.apache.org/docs/2.4/ 安装apache2: apt-get install apache2 安装apache2doc文档:a ...
- Ubuntu下apache2安装配置(内含数字证书配置)
Ubuntu下apache2安装配置(内含数字证书配置)安装命令:sudo apt-get updatesudo apt-get install apache2 配置1.查看apache2安装目录命令 ...
- Tomcat配置多个端口号或多个应用
一.在Tomcat下配置一个应用服务(service)中,配置多个端口号. 即一个service配置多个端口,项目可以通过多个端口访问. 修改tomcat-home\conf下的server.xml, ...
- Tomcat中配置多个端口
在tomcat的conf/server.xml中,配置多个端口,如下: <?xml version="1.0"?> <!--应用1,端口port="80 ...
- ubuntu 启用apache2 虚拟机配置
Ubuntu 启用apache2 虚拟机配置 http://jingyan.baidu.com/article/5d6edee20b78e999eadeecf7.html
- Tomcat配置远程调试端口
Tomcat配置远程调试端口 1.Linxu系统: apach/bin/startup.sh开始处中增加如下内容: declare -x CATALINA_OPTS="-server -Xd ...
- tomact配置域名和端口直接访问网站
tomact配置域名和端口直接访问网站,就是使用域名解析到主机,通过端口执行网站地址,实现访问,在上一章节中发布了两个web项目,但是都是执行同一个根文件夹,通过 http://localhost:8 ...
- linux apache虚拟主机配置(基于ip,端口,域名)
配置环境: linux版本:Centos6.4 httpd版本: [root@centos64Study init.d]# pwd/etc/init.d[root@centos64Study init ...
随机推荐
- numpy、pandas、scipy介绍
https://blog.csdn.net/LOLITA0164/article/details/80195124 numpy简介NumPy(Numeric Python)是一个Python包.它是一 ...
- 币安Binance API
本文介绍币安Binance API General API Information The base endpoint is: https://api.binance.com All endpoint ...
- HTML_body标签
常用符号:空格:  大于号:> 小于号: < 块级标签:H标签(加大加粗),P标签(段落间有间距),DIV(白板) 行内标签:SPAN标签(白板) <!- ...
- 学习计划 mysql 引擎
-- 什么是引擎? 按照我现在的勒戒,就可以提供 Mysql 对不同表的处理方式,各有优缺点. 就像名字一样,把我们数据库看成法拉利的话,引擎也就是发送机,有的跑的快,有的距离长....... -- ...
- elasticsearch更改mapping,不停服务重建索引(转)
原文:http://donlianli.iteye.com/blog/1924721?utm_source=tuicool&utm_medium=referral Elasticsearch的 ...
- 深入浅出 TCP/IP 协议栈
写的不错:http://www.cnblogs.com/onepixel/p/7092302.html#3899256
- visual studio code 的必装推荐插件plugin, vscode, vsc
An Old Hope Theme (theme, 推荐,且推荐它的 classic theme,安装后在颜色选项里选择,该插件的定制见文末) Cobalt2 (theme) Drac ...
- docker的安装,使用
1:安装:https://blog.csdn.net/yx_222/article/details/80936757 sudo apt-get install docker.io 2: 使用dock ...
- categoriy 重写函数会怎样?
From comp.lang.objective-C FAQ listing: "What if multiple categories implement the same method? ...
- Web前端开发推荐阅读书籍、学习课程下载
转自http://www.xuanfengge.com/fe-books.html 前言 学校里没有前端的课程,那如何学习JavaScript,又如何使自己成为一个合格的前端工程师呢? 除了在项目中学 ...