简体   繁体   English

轻量级的PHP服务器与应用程序捆绑在一起?

[英]Lightweight PHP server to bundle with application?

Does there exist some sort of PHP server that can be bundled with a locally-deployed application? 是否存在可以与本地部署的应用程序捆绑在一起的某种PHP服务器? It sounds wonky, but the end result is I can't use a remote web server to do anything. 听起来很奇怪,但最终结果是我无法使用远程Web服务器执行任何操作。 Clients will be downloading a package, and the plan is to use a Java backend that reads from a flat file. 客户端将下载软件包,并且计划使用从平面文件读取的Java后端。 The flat file contains settings and is modified through a GUI written in HTML/JS, and this is where the server would come in. The forms in HTML should be able to submit to the server, which does a simple file write to the flat file. 平面文件包含设置,并可以通过用HTML / JS编写的GUI进行修改,这就是服务器所在的位置。HTML格式的表单应能够提交到服务器,服务器将简单的文件写入平面文件。

Is there any simple, lightweight server that has that simple feature? 是否有任何具有该简单功能的简单,轻量级服务器? When running the executable for the application, it would start the installation process for the server before moving the web GUI files to the appropriate locations. 在为应用程序运行可执行文件时,它将在将Web GUI文件移动到适当位置之前启动服务器的安装过程。

Note that I'm doing this for a client, so I can't quite change the reqs and would rather not discuss their effectiveness. 请注意,我正在为客户执行此操作,因此我不能完全更改要求,而宁愿不讨论其有效性。 I would be ever thankful if people had suggestions for the server though! 如果有人对服务器有任何建议,我将不胜感激!

You should check out roadsend php. 您应该查看roadsend php。 It can compile php scripts into a binary with its own build in server. 它可以使用自己的内置服务器将php脚本编译为二进制文件。 https://github.com/weyrick/roadsend-php https://github.com/weyrick/roadsend-php

Since PHP 5.4, PHP have a built-in web server and this works on any system where PHP binaries exists. 从PHP 5.4开始,PHP具有内置的Web服务器,并且可以在存在PHP二进制文件的任何系统上使用。

$ cd ~/public_html
$ php -S localhost:8000

I can't think of any lighter server... 我想不到任何更轻巧的服务器...

http://php.net/manual/en/features.commandline.webserver.php http://php.net/manual/zh/features.commandline.webserver.php

Nanoweb might do the trick for you, it's an HTTP server written in PHP. Nanoweb可以为您解决问题,它是一个用PHP编写的HTTP服务器。 So long as the client has a PHP install you should be able to package things up nicely. 只要客户端安装了PHP,您就应该能够很好地打包它们。 In fact with a little extra effort you should be able to package up the PHP binary along with your code. 实际上,您只需付出一点额外的努力就可以将PHP二进制文件与代码打包在一起。

Nanoweb: http://nanoweb.si.kz/ 纳米网: http ://nanoweb.si.kz/

If you have a java backend, what do you need php for? 如果您有Java后端,则需要php做什么?

You could simply bundle a small java based webserver. 您可以简单地捆绑一个基于Java的小型Web服务器。
http://java-source.net/open-source/web-servers http://java-source.net/open-source/web-servers

A while ago I created a small web interface for Transmission (mac/linux bittorrent client) that needed to run a local web server with a custom PHP setup. 不久前,我为Transmission(mac / linux bittorrent客户端)创建了一个小型Web界面,该界面需要使用自定义PHP设置运行本地Web服务器。 I used lighttpd + php w/ fastcgi. 我用lighttpd + php w / fastcgi。 When zipped up, I believe, it weighted in at <3MBs. 我认为压缩后的重量为<3MB。 If you don't need to run any PHP lighttpd is only a few MB's (and light on resources) and offers a very flexible configuration. 如果您不需要运行任何PHP,那么lighttpd只有几个MB(并且占用资源很少),并且提供了非常灵活的配置。

Source: http://svn.recurser.com/transmission/trunk/cocoa/ 资料来源: http : //svn.recurser.com/transmission/trunk/cocoa/

If you're already using Java, you may want to look at Quercus , an implementation of PHP and many common extensions in Java. 如果您已经在使用Java,则可能需要看看Quercus ,它是PHP的实现以及Java中的许多常见扩展。 It's a bit restrictive, but it may fit your needs. 这有点限制性,但可能符合您的需求。

Like unomi, I don't really understand the situation, but I'll assume you do... 像unomi一样,我不太了解情况,但我假设您会...

Apache is by far the most popular and best-tested platform on which to run PHP, but in theory it should run on any web server that supports CGI/FastCGI. 到目前为止,Apache是​​运行PHP的最流行和测试最好的平台,但是从理论上讲,它应该可以在支持CGI / FastCGI的任何Web服务器上运行。 Alternatives include Lighttpd, nginx, and a few dozen others. 替代品包括Lighttpd,nginx和其他几十个。

Whatever you choose, the key is to pre-configure it and keep it self-contained in its own folder. 无论您选择什么,关键都是要对其进行预配置并将其独立包含在自己的文件夹中。 I think Apache would easily work here. 我认为Apache可以在这里轻松工作。 Set it to port 43948 or something; 将其设置为端口43948或其他名称; remove all unnecessary modules; 删除所有不必要的模块; pare down the httpd.conf to its most basic requirements; 降低httpd.conf的最基本要求; allow only local connections; 只允许本地连接; and write clickable scripts (.bat or .sh or what have you) to start and stop it. 并编写可点击的脚本(.bat或.sh或您拥有的脚本)以启动和停止它。

This project is an interesting option ... 这个项目是一个有趣的选择 ...

An embeddable web server designed for (and written in) PHP. 专为PHP设计(并用PHP编写)的可嵌入Web服务器。 it handles the control of the assigned port, setting common environmental variables (such as $_SERVER, $_GET, $_POST and $_COOKIE) and calling a function or method in your application to delegate the request. 它处理分配端口的控制,设置常见的环境变量(例如$ _SERVER,$ _ GET,$ _ POST和$ _COOKIE),并在应用程序中调用函数或方法来委派请求。

The web server is able to be packaged in, and controlled from, your application. 可以将Web服务器打包到应用程序中并从中进行控制。 Therefore eliminating the requirement that your user have a standard web server installed and configured to use your web application. 因此,无需用户安装和配置标准Web服务器即可使用Web应用程序。 Combined with a database such as a flat-file database, a Berkley DB or SQLite, PHP Embeddable Web server can remove the need for the user to have any specialised libraries installed, except PHP (which is preinstalled in many Unix and Linux distros). 结合了平面文件数据库,Berkley DB或SQLite之类的数据库,PHP可嵌入Web服务器可以消除用户安装除PHP(许多Unix和Linux发行版中已预装的PHP)之外的任何专用库的需求。

I have used this. 我已经用过了 It does work.. It is cool. 它的确起作用。 As easy as... 一样容易...

# php server.php

You kind of have to get your hands dirty.. but it's TINY, a single file, and HIGHLY configurable... Word of warning though.. don't bother with this unless you know what a header, a class, a method, and an object, etc... And be prepared to apply that knowledge. 有点麻烦。.但是它很小,只有一个文件,并且可以高度配置...警告词..除非您知道标题,类,方法是什么,否则不要打扰。和一个物体等...并准备应用这些知识。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM