2012-06-08 56 views
0

如何配置apache,我可以在沒有DNS的本地服務器上測試它?我嘗試了下面的內容,但我不確定它有什麼問題。配置apache在本地服務器上測試

我正在使用Centos。

以下是我與

  1. 獲取IP地址| IP地址展示|

  2. to etc/hosts我添加了| 92.168.169.128 tst01 |。我從#1獲得了ip

  3. 重新啓動apache | apachectl -k優雅|

在Web瀏覽器中,如果我轉到http://tst01/,我會得到默認的Apache頁面。

這裏是我的httpd.conf

ServerRoot "/etc/apache2" 
PidFile ${APACHE_PID_FILE} 
User ${APACHE_RUN_USER} 
Group ${APACHE_RUN_GROUP} 
ServerTokens ProductOnly 
ServerAdmin [email protected] 

<VirtualHost *:80> 
    ServerName tst01 
    DocumentRoot /tmp/public_html 

    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined 
    ErrorLog /tmp/apache_logs/error.log 
    CustomLog /tmp/apache_logs/access.log combined  
</VirtualHost> 

我把一個很簡單的索引文件爲:/tmp/public_html/index.html。

的/ tmp目錄/的public_html的權限是755

我可以看到我的索引文件,如果我把這個在瀏覽器中:文件:///tmp/public_html/index.html

如果我期待in/tmp/apache_logs我沒有任何日誌。我甚至試圖打開權限777

任何建議讓我的index.html顯示,而不是默認的apache頁面?

+1

嘗試更改主機文件中的92.168.169.128至127.0.0.1 – Rishabh

+0

這也不起作用。我把以下內容放在hosts文件中:'127.0.0.1 \t \t localhost.localdomain localhost tst01' – brian

+0

剛放 '127.0.0.1 localhost'和 '127.0.0.1 tst01.net' – Rishabh

回答

0

問題是我使用了錯誤的配置文件。 Centos默認安裝了apache(我安裝在虛擬機上),並安裝在自定義目錄中。 Centos正在挑選它的版本,並且從未看過我的配置。我做了一個來看看配置的位置。

此外,/ etc/hosts文件應設置爲127.0.0.1。