PHP项目的Eclipse web服务器路径映射问题


Eclipse webserver path mapping issue with PHP project

我一直在阅读关于这个主题的其他帖子,尝试了帖子中的建议,但仍然有同样的问题。

我可以在外部浏览器中运行php,但不能在eclipse浏览器中运行。

htdoc目录下的工作空间

我已经通过调试器和运行配置。我正在运行xampp和eclipse。

在eclipse中,我有一个php文件要运行我选择run as网页,

事情就是这样。

Object not found!
The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again
If you think this is a server error, please contact the webmaster. 
Error 404
localhost
7/14/2011 3:49:58 AM
Apache/2.2.17 (Win32) mod_ssl/2.2.17 OpenSSL/0.9.8o PHP/5.3.4 mod_perl/2.0.4    Perl/v5.10.1 

我知道问题是什么,它的路径名称:路径为http://localhost/PHP2011X/FreelanceProjects/CLKeenan/CLKeenanfrm.php时我得到404但是当我拿出PHP2011X它工作得很好。

http://localhost/FreelanceProjects/CLKeenan/CLKeenanfrm.php

PHP2011X是eclipse中的项目名。

我还没能弄清楚如何更改本地url。谢谢你的帮助。

<Directory "C:/xampp/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.htmloptions
     for more information.
    Options Indexes FollowSymLinks Includes ExecCGI

     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
    AllowOverride All

     Controls who can get stuff from this server.
    Order allow,deny
    Allow from all
</Directory>

 DirectoryIndex: sets the file that Apache will serve if a directory
 is requested.
<IfModule dir_module>
    DirectoryIndex index.php index.pl index.cgi index.asp index.shtml index.html index.htm '
                   default.php default.pl default.cgi default.asp default.shtml default.html default.htm '
                   home.php home.pl home.cgi home.asp home.shtml home.html home.htm
</IfModule>

 The following lines prevent .htaccess and .htpasswd files from being 
 viewed by Web clients. 
<FilesMatch "^'.ht">
    Order allow,deny
    Deny from all
    Satisfy All
</FilesMatch>

 ErrorLog: The location of the error log file.
 If you do not specify an ErrorLog directive within a <VirtualHost>
 container, error messages relating to that virtual host will be
 logged here.  If you *do* define an error logfile for a <VirtualHost>
 container, that host's errors will be logged there and not here.
ErrorLog "logs/error.log"
ScriptLog "logs/cgi.log"

 LogLevel: Control the number of messages logged to the error_log.
 Possible values include: debug, info, notice, warn, error, crit,
 alert, emerg.
LogLevel warn
<IfModule log_config_module>
     The following directives define some format nicknames for use with
     a CustomLog directive (see below).
    LogFormat "%h %l %u %t '"%r'" %>s %b '"%{Referer}i'" '"%{User-Agent}i'"" combined
    LogFormat "%h %l %u %t '"%r'" %>s %b" common
    <IfModule logio_module>
       You need to enable mod_logio.c to use %I and %O
      LogFormat "%h %l %u %t '"%r'" %>s %b '"%{Referer}i'" '"%{User-Agent}i'" %I %O" combinedio
    </IfModule>

     The location and format of the access logfile (Common Logfile Format).
     If you do not define any access logfiles within a <VirtualHost>
     container, they will be logged here.  Contrariwise, if you *do*
     define per-<VirtualHost> access logfiles, transactions will be
     logged therein and *not* in this file.
    CustomLog "logs/access.log" common

     If you prefer a logfile with access, agent, and referer information
     (Combined Logfile Format) you can use the following directive.
    CustomLog "logs/access.log" combined
</IfModule>
<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://localhost/bar

     Alias: Maps web paths into filesystem paths and is used to
     access content that does not live under the DocumentRoot.
     Example:
     Alias /webpath /full/filesystem/path
     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:/xampp/cgi-bin/"
</IfModule>
<IfModule cgid_module>
     ScriptSock: On threaded servers, designate the path to the UNIX
     socket used to communicate with the CGI daemon of mod_cgid.
    Scriptsock "logs/cgi.sock"
</IfModule>

 "C:/xampp/cgi-bin" should be changed to whatever your ScriptAliased
 CGI directory exists, if you have that configured.
<Directory "C:/xampp/cgi-bin">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
</Directory>

 DefaultType: the default MIME type the server will use for a document
 if it cannot otherwise determine one, such as from filename extensions.
 If your server contains mostly text or HTML documents, "text/plain" is
 a good value.  If most of your content is binary, such as applications
 or images, you may want to use "application/octet-stream" instead to
 keep browsers from trying to display binary files as though they are
 text.
DefaultType text/plain
<IfModule mime_module>
     TypesConfig points to the file containing the list of mappings from
     filename extension to MIME-type.
    TypesConfig "conf/mime.types"

     AddType allows you to add to or override the MIME configuration
     file specified in TypesConfig for specific file types.
    AddType application/x-gzip .tgz
     AddEncoding allows you to have certain browsers uncompress
     information on the fly. Note: Not all browsers support this.
    AddEncoding x-compress .Z
    AddEncoding x-gzip .gz .tgz
     If the AddEncoding directives above are commented-out, then you
     probably should define those extensions to indicate media types:
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz

在您的web服务器上添加PHP2011X作为别名,因此Eclipse生成的地址确实有效。

另一个解决方案是定义一个从项目文件路径到项目URL路径的映射,但我认为Eclipse在这里确实不够灵活。但据我所知,这确实是不灵活的,而且大多数时候对我来说都不起作用。

所以我会去配置web服务器代替。如果您正在使用apache,则该指令称为Alias

编辑:

您可以尝试在<Directory "C:/xampp/htdocs">行之前放置Alias指令:

# Map Eclipse Project Name onto webroot (SO #6690405):
Alias /PHP2011X "C:/xampp/htdocs"
<Directory "C:/xampp/htdocs">
相关:在PHP和Eclipse中设置路径映射