Windows XP:将站点目录添加到Apache配置

时间:2011-06-02 16:58:44

标签: php apache zend-framework webserver apache-config

我的计算机上有一个本地Apache实例用于开发目的,我正在尝试将一个站点目录添加到Apache的httpconf文件中,该文件包含一些我尝试使用Eclipse调试的示例Web应用程序。我想添加的目录如下:

C:\ Eclipse_Workspace \ dummyWeb

添加路径后,我重新启动了Apache并尝试输入以下URL:

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 Server Community Edition进行PHP Web开发,使用Eclipse进行PDT。我的目标是能够通过Eclipse调试PHP Web应用程序。

更新:

看起来添加别名可能就是我想要的。不知道它们是如何工作的,目前正在阅读Apache文档。

更新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/,我将获得如下目录列表:

enter image description here

布兰登,谢谢你的建议。我想保持文档根完整,我将修改别名以移动一个目录,即 C:/ Eclipse_Workspace / ,以便我可以访问在eclipse中调试我的所有Web应用程序工作区。这个link在添加别名时也为潜在的Gotcha提供了一个很好的提示。

最后,但并非最不重要的是,对于任何有兴趣设置简单PHP开发环境的人来说,this PDF文档被证明是非常有价值的资源,请务必遵循说明。我使用了Zend's website提供的一体化软件包工具,它们几乎带有开箱即用的所有功能。

1 个答案:

答案 0 :(得分:1)

我查看了自己的apache文件,我认为你缺少一个更改文档根目录的地方:

#
# 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:\Eclipse_Workspace\dummyWeb"

我相信这是关于httpd.conf文件中的第210行,我在这里使用你的目录。