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

相关推荐
微风起皱3 小时前
Keepalived 高可用集群
运维·服务器
盖头盖3 小时前
【无参数_Rce】
服务器
LateFrames6 小时前
IIS 窗口不显示,但是任务栏状态正常
服务器·windows·microsoft
feng68_6 小时前
HAProxy算法实践
linux·运维·haproxy
志栋智能6 小时前
AI驱动的系统自动化巡检:重塑IT基石的智慧“守护神”
大数据·运维·人工智能·云原生·自动化
DeeplyMind7 小时前
第23章 ROCm虚拟化栈Docker化实战
运维·docker·容器
吹牛不交税7 小时前
在vmware中右键SSH连接虚拟机报错Could not resolve hostname
linux·服务器·ssh
西柚云8 小时前
把Codex装进VSCode!OpenAI编程助手插件版来了
服务器·ide·vscode·ai编程·codex
xiaoliuliu123459 小时前
Xshell-7.0.0111p安装步骤详解(附SSH连接与远程命令教程)
运维·ssh
gaize12139 小时前
服务器是什么?用来做什么?基本属性有什么?如何配置和挑选?
运维·服务器