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

一、背景

由于服务器资源受限(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端口映射文件

设置方式如图:

主要代码:

html 复制代码
NameVirtualHost *:8868
<VirtualHost *:8868>
    ServerAdmin 1181761347@qq.com
    DocumentRoot "D:\SDWS_NEW\frontEnd\DianSuiWeiShi3\unpackage\dist\build\web"
    ServerName newxianglin.cn
    ErrorLog "logs/newxianglin_sdws.log"
    CustomLog "logs/newxianglin_sdws.log" common
	<Directory "D:\SDWS_NEW\frontEnd\DianSuiWeiShi3\unpackage\dist\build\web">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks Includes ExecCGI

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   AllowOverride FileInfo AuthConfig Limit
    #
    AllowOverride All

    #
    # Controls who can get stuff from this server.
    #
    Require all granted
	</Directory>
</VirtualHost>

三、效果

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

相关推荐
CDN36021 分钟前
SDK 游戏盾接入闪退 / 初始化失败?依赖冲突与兼容修复
运维·游戏·网络安全
KOYUELEC光与电子努力加油41 分钟前
JAE日本航空电子推出满足汽车市场小型防水最新需求的MX80系列连接器
服务器·科技·单片机·汽车
C+++Python1 小时前
Linux/C++多进程
linux·运维·c++
最贪吃的虎1 小时前
GitHub推送又超时了?试试SSH
运维·ssh·github
XZY0281 小时前
如何使用grpc
运维·服务器
rleS IONS1 小时前
SQL2000在win10上安装的方法
运维·服务器
zly35002 小时前
centos7 sshd无法启动
linux·运维·服务器
七夜zippoe2 小时前
腾讯云轻量服务器部署OpenClaw实战:打造智能日程管理助手
服务器·云计算·腾讯云·openclaw·腾讯云openclaw玩虾大赛
IMPYLH3 小时前
Linux 的 hostid 命令
linux·运维·服务器·bash
山峰哥3 小时前
告别“点点点”:AI 如何重构我们的测试体系与质量防线
服务器·汇编·数据库·人工智能·性能优化·重构