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

相关推荐
Web极客码7 分钟前
WordPress管理员角色详解及注意事项
运维·服务器·wordpress
geinvse_seg16 分钟前
中小团队如何低成本搭建项目管理系统?基于 Ubuntu 的 Dootask 私有化部署实战
linux·运维·ubuntu
星辰徐哥17 分钟前
鸿蒙金融理财全栈项目——上线与运维、用户反馈、持续迭代优化
运维·金融·harmonyos
CSCN新手听安17 分钟前
【linux】高级IO,以ET模式运行的epoll版本的TCP服务器实现reactor反应堆
linux·运维·服务器·c++·高级io·epoll·reactor反应堆
丶伯爵式18 分钟前
Ubuntu 24.04 更换国内软件源指南 | 2026年3月26日
linux·运维·ubuntu·国内源·升级
xingyuzhisuan23 分钟前
租用GPU服务器进行深度学习课程教学的实验环境搭建
运维·人工智能·深度学习·gpu算力
Java后端的Ai之路42 分钟前
Linux端口进程查找与终止教程
linux·运维·服务器
busy dog~乌鸦~1 小时前
【THM-题目答案】:Web Fundamentals-How The Web Works-DNS in Detail: Domain Hierarchy
运维·web安全·网络安全·系统安全
奇妙之二进制2 小时前
zmq源码分析之own_t
服务器·网络
mounter6253 小时前
深度解析:Linux 内核为何要移除“直接映射” (Direct Map)?
linux·运维·服务器·security·linux kernel·direct mem map