Ary*_*itz 2 linux web-server virtualhost apache-2.2
我以前使用过 cPanel,它有一个名为Add on Domains的功能,它允许 Web 域指向public_html.
我已经切换到没有 cPanel 的 Linux 服务器,并且想在 Apache 中做同样的事情。
我该怎么做?
在 Apache 中,这称为虚拟主机。
Apache wesbite 有一个配置示例,我将在下面借用。显然,您想用自己的替换示例 DocumentRoots 和 ServerNames,并确保正确设置了 DNS。
# 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.example.com
# Other directives here
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /www/example2
ServerName www.example.org
# Other directives here
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)