gpt4 book ai didi

linux - 使用不同的域名在相同的 IP 地址中提供相同的内容

转载 作者:太空宇宙 更新时间:2023-11-04 05:43:54 24 4
gpt4 key购买 nike

域“www.abc.lk”的 Apache Web 服务器已配置并托管在 IP 地址为 192.168.2.105 的托管服务器中。另一个名为“www.def.lk”的域名也应配置相同的内容,不得有任何重复。解释一下针对上述要求的基于名称的虚拟主机的 Apache 服务器的配置?

最佳答案

您必须配置两个虚拟主机具有相同的 DocumentRoot 但不同的 ServerNames

http://httpd.apache.org/docs/2.2/vhosts/examples.html

# Ensure that Apache listens on port 80
Listen 80

# Listen for virtual host requests on all IP addresses
NameVirtualHost *:80

<VirtualHost *:80>
DocumentRoot /www/example1
ServerName www.abc.com

# Other directives here

</VirtualHost>

<VirtualHost *:80>
DocumentRoot /www/example1
ServerName www.123.com

# Other directives here

</VirtualHost>

关于linux - 使用不同的域名在相同的 IP 地址中提供相同的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32263914/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com