簡體   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