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

相关推荐
mifengxing5 分钟前
文件逻辑结构、物理结构与磁盘空闲存储空间管理
大数据·linux·运维·操作系统·计算机408
xcLeigh33 分钟前
Go入门:无类型常量与类型常量的区别
服务器·开发语言·golang
小此方2 小时前
Re:Linux系统篇(五十七)线程篇 · 十:基于环形缓冲的生产者消费者模型与信号量
linux·运维·驱动开发
fanged2 小时前
Linux的DD命令
linux·运维·服务器
华清远见成都中心3 小时前
FreeRTOS事件组(Event Group)的工作机制分析
服务器·网络·网络协议
xiaoxiangsiyan3 小时前
RHCE2026云原生路线EX188和EX288完整备考指南
运维·网络·云原生·自动化
九硕智慧建筑一体化厂家3 小时前
从照明节能到碳排可见:能碳平台助力机房迈向 “零碳” 未来
运维·笔记·智慧城市
张洛闻Eren3 小时前
MySQL 管理复制拓扑【MySQL第四课】
linux·运维·数据库·mysql
Meya11274 小时前
RFID 机房资产管理系统:告别手工台账,实现资产全流程自动管控
大数据·服务器
西安景驰电子4 小时前
《PTP精确时间协议系列》第二篇:工程部署、调试与性能优化
运维·服务器·网络·数据库·windows·性能优化