php 有没有简单的PHP开发服务器?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3004696/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 08:24:13  来源:igfitidea点击:

Is there a simple PHP development server?

phpwebserver

提问by mdashx

When writing web apps in Python, it's brain dead easy to run a development server. Django and Google App Engine (GAE) both ship with simple servers.

在用 Python 编写 Web 应用程序时,运行开发服务器很容易。Django 和 Google App Engine (GAE) 都带有简单的服务器。

The main feature I'm looking for is no configuration. I want something like the GAE dev server where you just pass the directory of the app as a parameter when the server is started.

我正在寻找的主要功能是没有配置。我想要类似 GAE 开发服务器的东西,您只需在服务器启动时将应用程序的目录作为参数传递。

Is there a reason that this is more difficult with PHP?

有没有理由让 PHP 更难?

采纳答案by Max Ruf

Use XAMPP: http://www.apachefriends.org/en/xampp.htmlIts easy to install and config.

使用 XAMPP:http: //www.apachefriends.org/en/xampp.html它易于安装和配置。

EDIT:
since PHP 5.4 (which was released 2 years after this answer) there's a built-in web-server. Today this is inaccurate, please use the method provided by k0pernikus in his answer.

编辑:
自 PHP 5.4(在此答案发布 2 年后发布)以来,有一个内置的网络服务器。今天这个不准确,请使用k0pernikus在他的回答中提供的方法。

回答by HBv6

Actually PHP 5.4.0 recently presented its built-in web server:

实际上 PHP 5.4.0 最近推出了它的内置 Web 服务器

cd ~/public_html
php -S localhost:8000

回答by ssokolow

If it's a feasible option on whatever platform you're using, PHP 5.4 has a Django-like development server.

如果它在您使用的任何平台上都是可行的选择,那么 PHP 5.4 有一个类似 Django 的开发服务器

You may also want the snippetI use to detect the development server and replicate the two most common uses of mod_rewrite. (Hiding index.phpin URLs and passing static files through to be served)

您可能还需要我用来检测开发服务器并复制 mod_rewrite 的两个最常见用途的代码段。(隐藏index.php在 URL 中并传递静态文件以供服务)

(Yes, there is a built-in command-line switch for that, but it doesn't quite match the mod_rewrite snippet most people use and caused spurious 404 errors for me because of that mismatch.)

(是的,有一个内置的命令行开关,但它与大多数人使用的 mod_rewrite 片段不太匹配,并且由于不匹配而导致虚假 404 错误。)

回答by ctcherry

Update: I've developed a docker based version that I have started using instead of easy_php_dev: localdev

更新:我开发了一个基于 docker 的版本,我已经开始使用它来代替 easy_php_dev:localdev

easy_php_devmakes multi-site php development very easy and fast. Only limitation is it is designed only for OSX. Disclosure: I'm the author.

easy_php_dev使多站点 php 开发变得非常容易和快速。唯一的限制是它仅适用于 OSX。披露:我是作者。

回答by Nishchit Dhanani

Try using batchfile

尝试使用批处理文件

  1. Open notepad
  2. php -S localhost:8000
  3. save file as .bat extension => server.bat
  4. now click on server.bat, your server is ready on http://localhost:8000.
  1. 打开记事本
  2. php -S 本地主机:8000
  3. 将文件另存为 .bat 扩展名 => server.bat
  4. 现在单击server.bat,您的服务器已在http://localhost:8000上准备就绪。

DEP

发展部

if you got error php not recognize any internal or external commandthen goto environment variable and edit path to php.exe

如果出现错误,php not recognize any internal or external command则转到环境变量并编辑 php.exe 的路径

"C:\wamp\bin\php\php5.4.3"

回答by fe_lix_

We have developed a very small development server which has a similar behavior as django development server.

我们开发了一个非常小的开发服务器,它具有与 django 开发服务器类似的行为。

The software is called sngand work with php and nginx. It is made in javascript and nodejs, you can install it very easily with npm :

该软件名为sng,可与 php 和 nginx 配合使用。它是用 javascript 和nodejs 制作的,你可以很容易地用 npm 安装它:

npm install sng

回答by Keeper

When I need a quick php web server for local testing I use QuickPHP

当我需要一个快速的 php web 服务器进行本地测试时,我使用QuickPHP

回答by fire

AppServhas always setup everything you need nicely!

AppServ总是能很好地设置您需要的一切!