我的主网站正常工作,但我想设置一个子域,但它总是显示主网站,而我已经复制了我的apache2.conf下面的主要部分
# Include the virtual host configurations: Listen 80 # This is the "main" server running on 67.208.112.97 DocumentRoot /var/www # This is the other address NameVirtualHost *:80 <VirtualHost *:80> DocumentRoot /var/www ServerName giantpixels.com.au <Directory “/var/www”> allow from all Options +Indexes </Directory> </VirtualHost> <VirtualHost *:80> DocumentRoot /home/gardenbook/wwwroot/gardenbook ServerName garden.giantpixels.com.au <Directory “/home/gardenbook/wwwroot/gardenbook”> allow from all Options +Indexes </Directory> </VirtualHost>
你不能混合使用VirtualHosts和非VirtualHosts。 从主Apache的httpdconfiguration中删除DocumentRoot
指令,并添加一个默认的VirtualHost
块:
# Include the virtual host configurations: Listen 80 # This is the other address NameVirtualHost *:80 # This VirtualHost will also be served when no Host # header was provided or the hostname is unknown. # See # http://httpd.apache.org/docs/2.2/vhosts/details.html <VirtualHost *:80> DocumentRoot /var/www ServerName giantpixels.com.au <Directory “/var/www”> allow from all Options +Indexes </Directory> </VirtualHost> <VirtualHost *:80> DocumentRoot /home/gardenbook/wwwroot/gardenbook ServerName garden.giantpixels.com.au <Directory “/home/gardenbook/wwwroot/gardenbook”> allow from all Options +Indexes </Directory> </VirtualHost>