由于服务器资源受限(IP资源或硬件资源),有时候希望一台服务器IP能有部署多个网页服务入口。
传统都是80端口映射为默认服务入口,当需要部署多个网页服务入口时,可以启用其他端口,不同端口映射到不同的网页服务。
通过这种方案,需要配置服务器的apache端口映射方案
通过设置apache vhost选项,支持对于特定端口支持映射到不同的本地入口网页文件。
编辑http.conf文件,找到Listen xxx,加上自己想要listen的端口
打开vhost对应目录,一般在~\apache\conf\extra对应目录,
设置方式如图:
主要代码:
NameVirtualHost *: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 # # 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
重启apache服务后,可以看到不同端口进入不同的网页入口