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

相关推荐
醉颜凉22 分钟前
网络安全必学:粘性MAC地址(Sticky MAC)原理与应用全解析
运维·服务器·网络·安全·web安全
不懂的浪漫1 小时前
ToDesk 连接 Linux 后分辨率过低的解决方法
linux·运维·数据库
晊晌_h1 小时前
嵌入式从0到精通——Linux C|TCP 并发服务器实现方案详解
服务器·开发语言·tcp/ip
姚不倒2 小时前
etcd 学习系列(七):排障指南 —— 常见问题与解决方案
运维·etcd
广州灵眸科技有限公司2 小时前
从手动三步到上电即连:4G模组systemd开机自连方案
linux·运维·服务器·开发语言·网络·人工智能·php
深念Y2 小时前
【保姆级教程】Proxmox VE (PVE) 安装 FreeBSD 完整指南
服务器·unix·系统·pve·freebsd·虚拟化平台
Lear2 小时前
Docker 私有仓库搭建与使用
运维·自动化运维
姚不倒3 小时前
etcd 学习系列(一):从业务需求出发,理解 etcd 是什么
运维·数据库·etcd
子非鱼a3 小时前
【WEB】[SWPU2019]Web1
java·服务器·前端
qq_452396233 小时前
第十篇:《eBPF 可观测性:零侵扰的深度内核追踪》
服务器·网络·php