如何使用 PDT 插件在 Eclipse 中设置/查看 PHP 服务器页面(用于 php)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10299890/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to set up/view PHP server pages in Eclipse with the PDT plugin (for php)
提问by Ozzy
I am trying to set up a PHP server on my localhost to run with the Eclipse PDT
.
I want to be able to view the PHP site I am developing on something like http://localhost/MySite/index.php
so that I can Run
it straight from Eclipse.
我正在尝试在我的本地主机上设置一个 PHP 服务器来运行Eclipse PDT
. 我希望能够查看我正在开发的 PHP 站点,http://localhost/MySite/index.php
以便我可以Run
直接从 Eclipse 中查看。
I am using IIS 7.5 (windows 7 home premium) for the PHP server.
我正在为 PHP 服务器使用 IIS 7.5(Windows 7 家庭高级版)。
So far I have followed these instructions, but have not been able to get it to work:
到目前为止,我已按照这些说明进行操作,但无法使其正常工作:
- Install
CGI
option in Windows Features - Install
IIS Manager
in Windows Features (so I can runinetmgr.exe
) - Download the NTS-version of php and extract the zip to
C:/php
- Rename
php.ini-development
tophp.ini
and set theextension_dir
variable - Run
inetmgr
and create a new website to run PHP applications (I removed theDefaultSite
):- Site Name:
My Site
- Physical Directory
C:/dev/MySite
- Application Pool:
DefaultAppPool
- Bindings:
- Host:
- IP Address:
All Unasigned
- Port:
80
- Site Name:
- In
inetmgr
: Click on handler mappings and add a newModule Mapping
:- Request Path:
*.php
- Module:
FastCGIModule
- Executable:
C:/php/php-cgi.exe
- Request Path:
CGI
Windows 功能中的安装选项IIS Manager
在 Windows 功能中安装(以便我可以运行inetmgr.exe
)- 下载 NTS 版本的 php 并将 zip 解压缩到
C:/php
- 重命名
php.ini-development
到php.ini
并设置extension_dir
变量 - 运行
inetmgr
并创建一个新网站来运行 PHP 应用程序(我删除了DefaultSite
):- 网站名称:
My Site
- 物理目录
C:/dev/MySite
- 应用池:
DefaultAppPool
- 绑定:
- 主持人:
- IP地址:
All Unasigned
- 港口:
80
- 网站名称:
- 在
inetmgr
:单击处理程序映射并添加一个新的Module Mapping
:- 请求路径:
*.php
- 模块:
FastCGIModule
- 可执行:
C:/php/php-cgi.exe
- 请求路径:
Now I have many problems:
现在我有很多问题:
In
IIS Manager
, when I clickEdit Site
>Test Settings
, there is a yellow exclamation-mark warning:Authorization: Cannot verify access to path (C:/dev/MySite)
:The server is configured to use pass-through authentication with a built-in account to access the specified physical path. However, IIS Manager cannot verify whether the built-in account has access. Make sure that the application pool identity has Read access to the physical path. If this server is joined to a domain, and the application pool identity is NetworkService or LocalSystem, verify that \$ has Read access to the physical path. Then test these settings again.
When I try to load any
.php
file directly from the webroot (C:/dev/MySite) it displays as plain-text in my web browserWhen I try to
Run
my project in Eclipse, it goes tohttp://localhost/MySite/index.php
and there is a404 Error: Website Not Found
When I go to
http://localhost/
in my web browser, I also get a404 Error
.
在 中
IIS Manager
,当我单击Edit Site
> 时Test Settings
,会出现黄色感叹号警告Authorization: Cannot verify access to path (C:/dev/MySite)
::服务器配置为使用带有内置帐户的直通身份验证来访问指定的物理路径。但是,IIS 管理器无法验证内置帐户是否具有访问权限。确保应用程序池标识对物理路径具有读取权限。如果此服务器已加入域,并且应用程序池标识为 NetworkService 或 LocalSystem,请验证 \$ 对物理路径具有读取访问权限。然后再次测试这些设置。
当我尝试
.php
直接从 webroot (C:/dev/MySite)加载任何文件时,它在我的 Web 浏览器中显示为纯文本当我
Run
在 Eclipse 中尝试我的项目时,它会转到http://localhost/MySite/index.php
并且有一个404 Error: Website Not Found
当我
http://localhost/
在我的网络浏览器中访问时,我也会得到一个404 Error
.
采纳答案by Xeoncross
I'm afraid I don't have an answer to you're question, but I wanted to share...
恐怕我无法回答您的问题,但我想分享...
I never was a fan of running PHP on IIS or Apache. So I built a portable, no-install-required copy of nginxthat I could move around with me or use on my Windows machines. (Just download the flavors of PHP, Nginx, and MySQL you want and start it). One of the reasons is that most production sites run nginx anyway, so this way I'm closer to what my server actually uses (unless you are on "shared-hosting" which still uses the Apache).
我从不喜欢在 IIS 或 Apache 上运行 PHP。所以我构建了一个便携式的、无需安装的 nginx 副本,我可以随身携带或在我的 Windows 机器上使用它。(只需下载您想要的 PHP、Nginx 和 MySQL 版本并启动它)。原因之一是大多数生产站点无论如何都运行 nginx,所以这样我更接近我的服务器实际使用的内容(除非您使用仍然使用 Apache 的“共享托管”)。
Second, I'm not sure why you need to "run" it from Eclipse. When you write PHP you usually are dealing with a lot of variables to get pages setup. I would say you need to worry more about adding Unit Tests to make sure things work right, and using a browser like Firefox (with firebug) for testing any requests you might be making. Things like AJAX, or dealing with session cookies often require more control than what Eclipse can give you.
其次,我不确定为什么需要从 Eclipse 中“运行”它。当您编写 PHP 时,您通常会处理许多变量来设置页面。我会说您需要更多地担心添加单元测试以确保一切正常,并使用像 Firefox(带有 firebug)这样的浏览器来测试您可能提出的任何请求。像 AJAX 或处理会话 cookie 之类的事情通常需要比 Eclipse 可以提供的更多的控制。
Bottom line, I'm not sure why you think you need to do this.
归根结底,我不确定您为什么认为需要这样做。
回答by Wil Moore III
If you download PHP 5.4.xyou will be able to use the built-in web server for all of your development needs.
如果您下载 PHP 5.4.x,您将能够使用内置的 Web 服务器来满足您的所有开发需求。
In your php folder, you would run:
在您的 php 文件夹中,您将运行:
php -S localhost:3030
Now you will be able to browse to http://localhost:3030/index.php
现在您将能够浏览到http://localhost:3030/index.php
If you were using the Aptana IDE (or anything comparable), you would set this up like so:
如果您使用的是 Aptana IDE(或任何类似的东西),您可以这样设置:
Your run configuration would be:
您的运行配置将是:
I don't personally use Aptana (I did a few years ago); however, I thought it would be interesting to try this to find out if the integration would be seamless or not. I have to say, I am pretty impressed at how Aptana gets out of your way so you can do just about whatever you want.
我个人不使用 Aptana(几年前我使用过);但是,我认为尝试此操作以了解集成是否无缝会很有趣。我不得不说,我对 Aptana 如何摆脱困境印象深刻,因此您可以随心所欲地做任何事情。
Finally, if you are wondering about the "$HOME/local/php/versions" listed in my "Start command", I drive multiple PHP versions with a tool called php-version. Please be aware that this tool targets Linux/Mac users; however, if more people are interested, I may do a windows/powershell port (NOTE: I am the author).
最后,如果您想知道我的“启动命令”中列出的“$HOME/local/php/versions”,我会使用一个名为php-version的工具驱动多个 PHP 版本。请注意,此工具面向 Linux/Mac 用户;但是,如果有更多人感兴趣,我可以做一个 windows/powershell 端口(注意:我是作者)。