PHP 开发/测试服务器
我需要一个简单的 php“开发”服务器,例如不是 apache。
在现代环境中,例如node.js,我可以在任何文件夹中运行node server.js
,并且它将作为运行server.js
指定的站点的服务器运行>。然后,我可以从不同的文件夹运行另一个节点进程,并且两个服务器永远不会干扰或妨碍彼此。
php 有类似的设置吗?
使用apache,在我看来,我需要提前“配置”服务器;我不能只是放入某个文件夹并在某个任意端口上提供其内容。
我想要一个命令,可以使用它从某个文件夹内部运行 php 服务器,并使用最少的配置,以成为仅用于开发/测试的服务器。
例如,假设该服务器名为 sps
,那么,我应该能够:
cd ~/code/proj1
sps
也许它可能需要一个简单的配置文件 sps.conf
来指定服务器的端口号服务器应该监听,也许还有有关数据库连接的信息;但仅此而已。
php 有这样的工具吗?
I need a simple "development" server for php, e.g. not apache.
In a modern environment, such as node.js, I can run node server.js
inside any folder, and it will run as a server running the site specified by server.js
. I can then run another node process from a different folder, and the two servers will never interfere or get in each other's way.
Is there a similar setup for php?
With apache, it seems to me that I need to "configure" the server ahead of time; I can't just drop into some folder and serve its content on some arbitrary port.
I want a command that I can use to run a php server from inside some folder, with minimum amount of configuration, for the purpose of being a development/testing only server.
For instance, suppose this server is called sps
, then, I should be able to:
cd ~/code/proj1
sps
Perhaps it could require a simple config file, sps.conf
that specifies the port number the server should listen to, plus maybe information about the database connection; but nothing more.
Does such a tool exist for php?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用当前版本的 PHP (< 5.4),您确实必须配置一个网络服务器(Apache、nginx、...) 来为您所在的目录提供服务将拥有您的网站——您将在其中工作的目录。
不过,一般来说,您只会有几个网站,这意味着您不必经常重新配置网络服务器。
如果您经常需要创建/测试一些小脚本,只需创建一个指向某些
tests
目录的 Apache VirtualHost,您将在其中放置所有测试脚本(我我的电脑上就有这个)。使用 PHP 5.4 (目前处于 alpha 阶段 - 因此还不能在生产服务器上使用 ^^),您将拥有 内置网络服务器,这应该可以回答您的问题。
With the current version of PHP (< 5.4), you indeed have to configure a webserver (Apache, nginx, ...) to serve the directory in which you'll have your website -- the directory in which you'll work.
Generally, though, you'll only have a couple of websites, which means you won't have to re-configure your webserver too often.
And if you often have to create / test some small scripts, just create an Apache VirtualHost that points to some
tests
directory, in which you'll put all your test scripts (I have exactly that on my computer).With PHP 5.4 (currently in alpha -- so not to be used on a production server just yet ^^), you'll have a built-in web server, which should pretty much answer your question.
尝试 XAMPP Lite 版本 http://www.apachefriends.org/en/xampp-windows.html
try XAMPP Lite version http://www.apachefriends.org/en/xampp-windows.html