Windows

http://localhost 不起作用,http://127.0.0.1 起作用

  • December 10, 2011

我正在使用 Apache 執行 Zend 並看到一個奇怪的行為….

如果我在瀏覽器 url 中輸入http://127.0.0.1>,它可以正常工作,但是在輸入:<http://localhost後,我會得到一個文件下載視窗,文件類型為:application/x-httpd-php

在我的 httpd.conf 文件中,我在 VirtualHost *:80 定義下有以下內容:

ServerName localhost

DocumentRoot E:\zend\Apache2\htdocs\my_project\public

Directory E:\zend\Apache2\htdocs\my_project\public

也許一些配置問題…誰能指導我..

從 httpd.conf 文件:

NOTE: Where filenames are specified, you must use forward slashes instead of backslashes (e.g., "c:/apache" instead of "c:\apache"). If a drive letter is omitted, the drive on which Apache.exe is located will be used by default. It is recommended that you always supply an explicit drive letter in absolute paths to avoid confusion.

所以改變

DocumentRoot E:\zend\Apache2\htdocs\my_project\public

DocumentRoot "e:/zend/Apache2/htdocs/my_project/public"

Directory E:\zend\Apache2\htdocs\my_project\public是配置文件的一部分,在該目錄中允許和/或禁用服務和功能,所以它必須像這樣:

&lt;Directory "e:/zend/Apache2/htdocs/my_project/public"&gt; some options &lt;/Directory&gt;

如果您在此處發布 httpd.conf 或將其上傳到某處並發布指向該文件的連結,則更容易指出問題所在

引用自:https://serverfault.com/questions/231546