繁体   English   中英

文档根目录不适用于Apache的虚拟主机设置

[英]Document Root doesn't work with Virtual Host setting for Apache

我在httpd.conf中这样设置VirtualHost:

<VirtualHost xxx.255.118.79:80>
    ServerAdmin hoge@hoge.foo.com
    DocumentRoot /var/www/html
    ServerName main.foo.com
    ErrorLog logs/main.foo.com-error_log
    TransferLog logs/main.foo.com-access_log
</VirtualHost>

<VirtualHost xxx.255.118.79:8080>
    ServerAdmin hoge@hoge.foo.com
    DocumentRoot /opt/another_www/
    ServerName anotherhost.foo.com
    ErrorLog logs/host.foo.com-error_log
    TransferLog logs/host.foo.com-access_log
</VirtualHost>

使用httpd -S看起来还可以。

[iron@birdwatch html]$ sudo httpd -S
VirtualHost configuration:
xxx.255.118.79:80      main.foo.com (/etc/httpd/conf/httpd.conf:1012)
xxx.255.118.79:8080    anotherhost.foo.com (/etc/httpd/conf/httpd.conf:1020)
Syntax OK

但是当我访问http://xxx.255.118.79:8080时 ,它仍然可以访问/ var / www / html。 您能告诉我如何使apache2为/ 8080端口服务/ opt / another_www吗?

谢谢!

我意识到,必须由运行Apache的本地计算机才能发现其中的域名。 这意味着它必须是本地IP地址或*。

<VirtualHost *:8080>
  ServerAdmin hoge@hoge.foo.com
  DocumentRoot /opt/another_www/

在将其更改为*之后,它开始在/ opt / another / www下提供文档。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM