Windows XP: Add site directory to Apache config
I have a local instance of Apache on my computer for development purposes, I'm trying to add a site directory, to Apache's httpconf file, that contains some sample web applications I'm trying to debug using Eclipse. The directory I'm trying to add is as follows:
C:\Eclipse_Workspace\dummyWeb
After adding the path, I restarted Apache and tried to enter a URL as :
http://localhost/Eclipse_Workspace/dummyWeb/enterGreeting.php
But I get the 404 error page. I'm not sure what I have to do to to get the page to open properly. I'm new to Apache server configuration and am using ApacheConf Lite as a GUI-based server settings editor. The new directory I added in the httpconf file looks like this:
<Directory "C:\Eclipse_Workspace\dummyWeb">
Options All
Allow from All
Order Allow,Deny
AllowOverride None
</Directory>
I also tried making the last slash a forward slash like the default root directory:
<Directory "C:\Eclipse_Workspace/dummyWeb">
Options All
Allow from All
Order Allow,Deny
AllowOverride None
</Directory>
Compared to the default root:
<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>
But I still get 404, what am I missing? Any help is appreciated.
Some other details, I'm using the Zend Server Community Edition for PHP web development and Eclipse with PDT. My goal is to be able to debug PHP web applications through Eclipse.
UPDATE:
Looks like adding an alias might be what I'm looking for. Not sure how they work though, currently reading through Apache documentation.
UPDATE 2:
Bingo! Looks like adding an alias did the trick. The relevant lines of configuration are as follows:
# 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 Fo开发者_JAVA百科llowSymLinks 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>
So if I punch in the following URL: http://localhost/webpath/
, I'll get a directory listing as follows:
Brandon, thanks for the suggestion. I want to keep the document root intact, I'm going to modify the alias to move up one directory, i.e. C:/Eclipse_Workspace/ so that I have access to debug all my web applications in the eclipse workspace. This link also provided a good tip on a potential Gotcha when adding an alias.
Last, but not least, for anyone interested in setting up a simple PHP Development environment, this PDF document proved a very valuable resource, make sure to follow the instructions. I used the all-in-one package tools provided on Zend's website, they pretty much come with everything out of the box.
I looked at my own apache file I think you are missing one spot of changing the document root:
#
# 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"
I believe this is about line 210 in the httpd.conf file, I am using your directory here.
精彩评论