Apache2.4 多端口虚拟目录配置

烈酒焚心 提交于 2020-02-22 15:15:32

步骤1.首先打开AppServ\Apache2.4\conf里面的httpd.conf文件。在里面找到:
LoadModule rewrite_module modules/mod_rewrite.so这行,将他前面的“#”去掉。

步骤2.找到:Include conf/extra/httpd-vhosts.conf将他前面的“#”去掉。(很关键)

步骤3: 添加端口,找到Listen 添加端口如下
#Listen 12.34.56.78:80
Listen 8888
Listen 8081

步骤4:到AppServ\Apache2.4\conf\extra里面的httpd-vhost.conf文件打开,在最后一行添加:

<VirtualHost 127.0.0.1:8081>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "E:/testservername/JQuery/CJSource/JS"
ServerName testservername
ErrorLog "logs/dummy-host2.example.com-error.log"
CustomLog "logs/dummy-host2.example.com-access.log" common

<Directory "E:/testservername/JQuery/CJSource/JS">
Options Indexes MultiViews
AllowOverride none
Require all granted
</Directory>
</VirtualHost>

PS:127.0.0.1:8081 可改为*:8081,8081为新添加的端口
DocumentRoot "E:/testservername/JQuery/CJSource/JS" 这个是新端口对应的虚拟路径
ServerName testservername 对应的域名,尽量不要写成localhost,避免和默认的域名localhost冲突

最后修改host文件:默认在C:\Windows\System32\drivers\etc目录下
在host文件中最后一行添加:127.0.0.1 testservername

重启Apache ,在浏览器输入:testservername:8081或者 127.0.0.1:8081 即可访问虚拟路径

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!