爲了開發目的,我的計算機上有一個本地Apache實例,我試圖向Apache的httpconf文件添加一個站點目錄,其中包含一些示例Web應用程序試圖使用Eclipse進行調試。我想補充的目錄如下:Windows XP:將站點目錄添加到Apache配置
C:\ Eclipse_Workspace \ dummyWeb
添加路徑後,我重新啓動Apache和試圖進入一個網址爲:
http://localhost/Eclipse_Workspace/dummyWeb/enterGreeting.php
但我得到了404錯誤頁面。我不確定我需要做些什麼才能使頁面正常打開。我是Apache服務器配置的新手,並且正在使用ApacheConf Lite作爲基於GUI的服務器設置編輯器。我在httpconf文件添加的新目錄看起來是這樣的:
<Directory "C:\Eclipse_Workspace\dummyWeb">
Options All
Allow from All
Order Allow,Deny
AllowOverride None
</Directory>
我也試圖使最後一個斜線斜線狀的默認根目錄:
<Directory "C:\Eclipse_Workspace/dummyWeb">
Options All
Allow from All
Order Allow,Deny
AllowOverride None
</Directory>
相比默認根:
<Directory "C:\Program Files\Zend\Apache2/htdocs">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
Options FollowSymLinks Indexes
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
Allow from all
#
# Controls who can get stuff from this server.
Order allow,deny
AllowOverride None
#
# Note that from this point forward you must specifically allow
# particular features to be enabled - so if something's not working as
# you might expect, make sure that you have specifically enabled it
# below.
#
#
# This should be changed to whatever you set DocumentRoot to.
</Directory>
但我仍然得到404,我錯過了什麼?任何幫助表示讚賞。
其他一些細節,我使用的Zend服務器社區版PHP網站開發和Eclipse PDT用。我的目標是能夠通過Eclipse調試PHP Web應用程序。
UPDATE:
貌似增加一個別名可能是什麼我要找的。不知道它們是如何工作的,目前正在閱讀Apache文檔。
UPDATE 2:
賓果!看起來像添加一個別名的伎倆。是配置的相關線路如下:
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
DocumentRoot "C:\Program Files\Zend\Apache2/htdocs"
.
.
.
.
<IfModule alias_module>
#
# Redirect: Allows you to tell clients about documents that used to
# exist in your server's namespace, but do not anymore. The client
# will make a new request for the document at its new location.
# Example:
# Redirect permanent /foo http://www.example.com/bar
#
# Alias: Maps web paths into filesystem paths and is used to
# access content that does not live under the DocumentRoot.
# Example:
Alias /webpath "C:/Eclipse_Workspace/dummyWeb/"
<Directory "C:/Eclipse_Workspace/dummyWeb/">
Options Indexes FollowSymLinks MultiViews ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
#
# If you include a trailing/on /webpath then the server will
# require it to be present in the URL. You will also likely
# need to provide a <Directory> section to allow access to
# the filesystem path.
#
# ScriptAlias: This controls which directories contain server scripts.
# ScriptAliases are essentially the same as Aliases, except that
# documents in the target directory are treated as applications and
# run by the server when requested rather than as documents sent to the
# client. The same rules about trailing "/" apply to ScriptAlias
# directives as to Alias.
ScriptAlias /cgi-bin/ "C:\Program Files\Zend\Apache2/cgi-bin/"
</IfModule>
所以,如果我一拳以下網址:http://localhost/webpath/
,我會得到一個目錄列表如下:
布蘭登,謝謝這個建議。我想保持文檔根完好,我要去修改別名移一個目錄,即C:/ Eclipse_Workspace/,使我有機會調試在Eclipse工作區中所有的Web應用程序。當添加別名時,這個link也提供了一個很好的提示。
最後但並非最不重要的是,對於任何有興趣設置簡單的PHP開發環境的人來說,this PDF文檔證明是一個非常有價值的資源,請務必按照說明操作。我使用了Zend's website上提供的一體化軟件包工具,它們幾乎都帶有一切開箱即用的功能。
是否有任何已經在端口80上聽不到apache的東西? – lockdown 2011-06-02 17:25:16