apache 虚拟主机不起作用

apache 虚拟主机不起作用

我想为我的域配置虚拟主机,以使用同一台服务器托管两个站点。以下是输出apache2ctl -S

AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
VirtualHost configuration:
*:80                   is a NameVirtualHost
         default server 127.0.1.1 (/etc/apache2/sites-enabled/000-default.conf:1)
         port 80 namevhost 127.0.1.1 (/etc/apache2/sites-enabled/000-default.conf:1)
         port 80 namevhost www.kahveciderin.com (/etc/apache2/sites-enabled/kahveciderin.com.conf:1)
                 alias www.kahveciderin.com
                 alias kahveciderin.com
         port 80 namevhost www.returnnull.xyz (/etc/apache2/sites-enabled/returnnull.xyz.conf:2)
                 alias www.returnnull.xyz
                 alias returnnull.xyz
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex default: dir="/var/run/apache2/" mechanism=default 
Mutex mpm-accept: using_defaults
Mutex watchdog-callback: using_defaults
Mutex rewrite-map: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
Define: ENABLE_USR_LIB_CGI_BIN
User: name="www-data" id=33 not_used
Group: name="www-data" id=33 not_used

问题是两个域名都使用 /var/www/html 作为其 documentroot

答案1

Apache 中的 VirtualHosts 可以拥有自己的 documentRoot。您只需在每个虚拟主机的块中指定正确的 DocumentRoot 即可。

相关内容