问题描述
我已经有一个我付费购买的网络服务器,我想使用 Thrift 和 PHP 在它上面公开一些服务.
I already have a web server that I pay for, and I want to expose some services on it using Thrift and PHP.
我的问题是:我可以使用托管在默认端口上的普通 PHP 运行 Thrift 服务器吗(与托管网页的方式相同),而不是让单独的 PHP 应用程序运行在某个时髦的晦涩端口上.这样我就不必更改服务器配置(即使我想这样做我也做不到).
My question is: can I run a Thrift server using normal PHP that's hosted on the default port (the same way web pages are hosted) instead of having a separate PHP application that runs on some funky obscure port. This way I wouldn't have to change the server configuration (which is something I'm not able to do even if I wanted to).
谢谢
也许我应该澄清一点.一旦我使用 .thrift 文件定义了我的服务,是否可以:
maybe I should clarify a bit more. Once I've defined my service using a .thrift file, is it possible to:
- 运行 thrift 代码生成器
- 将生成的代码放到我的网络服务器上
- 创建一个 index.php,上面写着(用伪代码)创建服务的新实例,并处理传入的请求"?
推荐答案
好吧,我自己找到了答案!
Okay, well I have figured out the answer on my own!
如果您在服务器端使用 TPhpStream
,您就可以处理作为常规 http 请求传入的请求.
If you use a TPhpStream
on the server side, you are able to serve requests coming in as regular http requests.
非常感谢 Rob Wilkerson https://github.com/robwilkerson/Thrift-Client-Server-Example--PHP-.
Many thanks to Rob Wilkerson https://github.com/robwilkerson/Thrift-Client-Server-Example--PHP-.
我还在 http://willwarren.com/2012/01/24/creating-a-public-api-with-apache-thrift/
这篇关于是否可以在常规 Web 服务器上使用 Apache Thrift?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!