Ubuntu 14.04服務器,Apache2。我在domain.tld下有一個Prestashop網店,工作正常。 我現在想在我的服務上安裝webmail,所以我添加了一個指向/ var/www/webmail的虛擬主機。儘管配置正確,NamedVirtiaulHosts仍然無法工作
但是,當我去webmail.domain.tld,我總是得到重定向到domain.tld。
我已經谷歌了很多,它看起來不錯。這是DUMP_VHOSTS
[email protected]:/etc/apache2# apachectl -t -D DUMP_VHOSTS
VirtualHost configuration:
*:443 is a NameVirtualHost
default server www.domain.tld (/etc/apache2/sites-enabled/domain.tld.conf:1)
port 443 namevhost www.domain.tld (/etc/apache2/sites-enabled/domain.tld.conf:1)
alias www.domain.tld
alias domain.tld
port 443 namevhost webmail.domain.tld (/etc/apache2/sites-enabled/webmail.domain.tld.conf:1)
alias webmail.domain.tld
*:80 is a NameVirtualHost
default server www.domain.tld (/etc/apache2/sites-enabled/domain.tld.conf:48)
port 80 namevhost www.domain.tld (/etc/apache2/sites-enabled/domain.tld.conf:48)
alias www.domain.tld
alias domain.tld
port 80 namevhost webmail.domain.tld (/etc/apache2/sites-enabled/webmail.domain.tld.conf:39)
alias webmail.domain.tld
輸出我還添加了webmail.domain.tld到我的主機文件(127.0.0.1),當我測試使用telnet 80,它也不起作用。
我發現很多帖子說我必須添加NamedVirtualHost:80,但似乎不贊成,因爲我然後得到一個錯誤,該命令不再起作用。 我也檢查了httpd.conf的REWRITES,但找不到一個。我也嘗試刪除「domain.tld」作爲默認網站的別名,但這也沒有任何區別。
相關的配置(2個conf文件):
<VirtualHost *:443>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerName www.domain.tld
ServerAlias www.domain.tld domain.tld
ServerAdmin [email protected]
DocumentRoot /var/www/domain.tld/public_html
# ....
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerName www.domain.tld
ServerAlias www.domain.tld domain.tld
ServerAdmin [email protected]
DocumentRoot /var/www/domain.tld/public_html
# ....
</VirtualHost>
<VirtualHost *:443>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerName webmail.domain.tld
ServerAlias webmail.domain.tld
ServerAdmin [email protected]
DocumentRoot /var/www/webmail
# ....
</VirtualHost>
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerName webmail.domain.tld
ServerAlias webmail.domain.tld
ServerAdmin [email protected]
DocumentRoot /var/www/webmail
# ....
</VirtualHost>
請闡明這光。
那麼,實際的配置是什麼樣的? – IMSoP
更新了我的帖子,添加了相關配置。 – Boland
不知道爲什麼這會收到一個-1沒有評論,非常有用。 但我解決了它......當然。它在一個FireFox的私人窗口中工作...所以這是一個緩存問題:@ – Boland