即使我停用了 Apache2 中的預設虛擬主機,為什麼我也無法擺脫預設的 index.html?

即使我停用了 Apache2 中的預設虛擬主機,為什麼我也無法擺脫預設的 index.html?

我創建了一個虛擬主機設定文件,並使用 a2dissite default 禁用了預設設定(這是一個非常標準的 Ubuntu 10.04 安裝)。但無論我如何嘗試,我的 Apache2 伺服器只是繼續顯示預設的 index.html 頁面,而不是我在虛擬主機檔案中設定的 index.php 頁面。有人可以幫助我我所缺少的東西嗎?詳情如下:

無預設設定:

ls -l /etc/apache2/sites-enabled/
total 0
lrwxrwxrwx 1 root root 51 May  5 13:32 webmin.1273066327.conf -> /etc/apache2/sites-available/webmin.1273066327.conf
lrwxrwxrwx 1 root root 34 May 30 11:03 www.accontax.be -> ../sites-available/www.accontax.be

相關虛擬主機的內容:

cat /etc/apache2/sites-enabled/www.accontax.be

<VirtualHost *>
    ServerName  www.accontax.be
    ServerAlias accontax.be

    DirectoryIndex index.php
    DocumentRoot /var/www/drupal/

    <Directory /var/www/drupal/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride None
            Order allow,deny
            allow from all
    </Directory>
</VirtualHost>

httpd.conf的內容:

cat /etc/apache2/httpd.conf

Listen 80
NameVirtualHost *

我的 apache2.conf 中也有這些相關行:

# Include generic snippets of statements
Include /etc/apache2/conf.d/

# Include the virtual host configurations:
Include /etc/apache2/sites-enabled/

當我訪問時http://www.accontax.be我希望 apache2 伺服器轉到 /var/www/drupal 子目錄並開始提供 index.php 服務,但它只是繼續從 /var/www 目錄提供 index.html 服務。我已經重新載入配置,重新啟動伺服器,刪除瀏覽器快取。沒有改變。

可能我錯過了一個簡單但關鍵的步驟,但我就是找不到它。

PS:當我 ssh 到伺服器並嘗試瀏覽本地主機時,它按我的預期工作!

答案1

我假設您的主機名稱是正確的(li141-187.members.linode.com)

在 /etc/apache2/httpd.conf 中更改以下行,

NameVirtualHost *NameVirtualHost 109.74.194.187:80

& 您的 /etc/apache2/sites-enabled/webmin.1273066327.conf 檔案中的第 1 行可能存在重複的 NameVirtualHost。如果是,刪除該行。

& 編輯 /etc/apache2/sites-enabled/000-default 檔案中的 VirtualHost 定義,如下所示。

<虛擬主機109.74.194.187:80>
   伺服器名稱 109.74.194.187
   …………

& 編輯 /etc/apache2/sites-enabled/www.accontax.be 中的行,如下所示。

<虛擬主機109.74.194.187:80>
   伺服器名稱 accontax.be
   伺服器別名 www.accontax.be
   …………

然後apache2ctl restart

& 並檢查您綁定的區域文件中的 accontax.be,它應該類似於下面的配置。

38400 美元
@ IN SOA accontax.be li141-187.members.linode.com。 (
            SOA_SERIAL_NUMBER
            10800
            3600
            604800
            38400)
accontax.be。在 NS ns1.linode.com。
accontax.be。在 NS ns2.linode.com。
accontax.be。在 109.74.194.187 中
www.accontax.be。在 109.74.194.187 中
ftp.accontax.be。在 109.74.194.187 中
webmail.accontax.be。在 109.74.194.187 中
mail.accontax.be。在 109.74.194.187 中
accontax.be。在 MX 5 mail.accontax.be 中。
accontax.be。在 TXT 中“v=spf1 a mx a:accontax.be ip4:109.74.194.187 ?全部”

應該有您自己的網域序號,intodns.com 是這麼說的。將 SOA_SERIAL_NUMBER 變更為您自己的上述值。

& 此連結將為您提供有關 DNS 配置的更多資訊。 http://www.intodns.com/accontax.be

看來你正在使用 webmin。最好在 webmin 中為您完成所有這些更改。檢查「伺服器」選單下的所有內容,在 apache 選單中,在更改任何內容之前檢查您的模組配置是否正常。並且將 webmin 中 apache 的啟動指令更改為 apache2ctl。不允許 webmin 使用 /etc/init.d/apache2 腳本。

相關內容