apache一台服务器如何通过不同端口映射不同网页服务入口 ...

打印 上一主题 下一主题

主题 996|帖子 996|积分 2988

一、配景

由于服务器资源受限(IP资源或硬件资源),偶尔候盼望一台服务器IP能有摆设多个网页服务入口。
传统都是80端口映射为默认服务入口,当必要摆设多个网页服务入口时,可以启用其他端口,不同端口映射到不同的网页服务。
通过这种方案,必要配置服务器的apache端口映射方案
二、方案

2.1 大体原理

通过设置apache vhost选项,支持对于特定端口支持映射到不同的本地入口网页文件。
2.2 操纵步骤

1、设置http.conf,监听其他必要启用的端口

编辑http.conf文件,找到Listen xxx,加上自己想要listen的端口

2、设置vhost端口

打开vhost对应目次,一样平常在~\apache\conf\extra对应目次,

3、设置vhost端口映射文件

设置方式如图:

主要代码:
  1. NameVirtualHost *:8868
  2. <VirtualHost *:8868>
  3.     ServerAdmin 1181761347@qq.com
  4.     DocumentRoot "D:\SDWS_NEW\frontEnd\DianSuiWeiShi3\unpackage\dist\build\web"
  5.     ServerName newxianglin.cn
  6.     ErrorLog "logs/newxianglin_sdws.log"
  7.     CustomLog "logs/newxianglin_sdws.log" common
  8.         <Directory "D:\SDWS_NEW\frontEnd\DianSuiWeiShi3\unpackage\dist\build\web">
  9.     #
  10.     # Possible values for the Options directive are "None", "All",
  11.     # or any combination of:
  12.     #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
  13.     #
  14.     # Note that "MultiViews" must be named *explicitly* --- "Options All"
  15.     # doesn't give it to you.
  16.     #
  17.     # The Options directive is both complicated and important.  Please see
  18.     # http://httpd.apache.org/docs/2.4/mod/core.html#options
  19.     # for more information.
  20.     #
  21.     Options Indexes FollowSymLinks Includes ExecCGI
  22.     #
  23.     # AllowOverride controls what directives may be placed in .htaccess files.
  24.     # It can be "All", "None", or any combination of the keywords:
  25.     #   AllowOverride FileInfo AuthConfig Limit
  26.     #
  27.     AllowOverride All
  28.     #
  29.     # Controls who can get stuff from this server.
  30.     #
  31.     Require all granted
  32.         </Directory>
  33. </VirtualHost>
复制代码
三、效果

重启apache服务后,可以看到不同端口进入不同的网页入口



免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

花瓣小跑

金牌会员
这个人很懒什么都没写!
快速回复 返回顶部 返回列表