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服务后,可以看到不同端口进入不同的网页入口

相关推荐
阿巴~阿巴~几秒前
从帧到包:深入解析链路层与局域网通信的核心机制
服务器·网络·网络协议·tcp/ip·智能路由器·mac·数据链路层
rfidunion9 分钟前
ubuntu下使用qemu模拟ARM(一)-------安装samba服务器
服务器·arm开发·ubuntu
HIT_Weston13 分钟前
90、【Ubuntu】【Hugo】搭建私人博客:侧边导航栏(四)
linux·运维·ubuntu
回忆是昨天里的海15 分钟前
dockerfile-镜像分层机制
linux·运维·服务器
翼龙云_cloud15 分钟前
阿里云渠道商:阿里云弹性伸缩有哪几种
服务器·阿里云·云计算
2501_9419820516 分钟前
基于自动化协议的企微外部群消息调度与状态回执实现逻辑
运维·自动化·企业微信
双层吉士憨包18 分钟前
如何安全访问 Kickass Torrents:代理选择、设置与最佳实践(2026)
运维·服务器
爱宇阳18 分钟前
Windows 通过 SSH 下载服务器目录并完整上传到指定服务器目录(scp / rsync 实战教程)
服务器·windows·ssh
JY.yuyu22 分钟前
Windows Server服务器数据备份 / 活动目录(AD域)
运维·服务器
三翼鸟数字化技术团队23 分钟前
搭建自己的MCP服务器
运维·服务器·人工智能