是否可以在常规Web服务器上使用Apache Thrift?

时间:2022-10-06 10:23:17

I already have a web server that I pay for, and I want to expose some services on it using Thrift and PHP.

我已经有一个我付费的Web服务器,我想使用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).

我的问题是:我可以使用托管在默认端口上的普通PHP运行Thrift服务器(与托管网页的方式相同),而不是在一些时髦的模糊端口上运行单独的PHP应用程序。这样我就不必更改服务器配置(即使我想这也是我无法做到的)。

Thanks

谢谢

EDIT: maybe I should clarify a bit more. Once I've defined my service using a .thrift file, is it possible to:

编辑:也许我应该澄清一点。一旦我使用.thrift文件定义了我的服务,是否可以:

  1. Run the thrift code generator
  2. 运行thrift代码生成器
  3. Take the generated code and put it on my webserver
  4. 获取生成的代码并将其放在我的网络服务器上
  5. Create an index.php which says (in pseudocode) "create a new instance of the service, and handle incoming requests"?
  6. 创建一个index.php,它表示(在伪代码中)“创建一个新的服务实例,并处理传入的请求”?

1 个解决方案

#1


12  

Okay, well I have figured out the answer on my own!

好吧,我已经找到了自己的答案!

If you use a TPhpStream on the server side, you are able to serve requests coming in as regular http requests.

如果在服务器端使用TPhpStream,则可以作为常规http请求提供请求。

Many thanks to Rob Wilkerson https://github.com/robwilkerson/Thrift-Client-Server-Example--PHP-.

非常感谢Rob Wilkerson https://github.com/robwilkerson/Thrift-Client-Server-Example--PHP-。

I also blogged about how to implement a simple example with PHP and Python at http://willwarren.com/2012/01/24/creating-a-public-api-with-apache-thrift/

我还在http://willwarren.com/2012/01/24/creating-a-public-api-with-apache-thrift/上写了关于如何使用PHP和Python实现一个简单示例的博客

#1


12  

Okay, well I have figured out the answer on my own!

好吧,我已经找到了自己的答案!

If you use a TPhpStream on the server side, you are able to serve requests coming in as regular http requests.

如果在服务器端使用TPhpStream,则可以作为常规http请求提供请求。

Many thanks to Rob Wilkerson https://github.com/robwilkerson/Thrift-Client-Server-Example--PHP-.

非常感谢Rob Wilkerson https://github.com/robwilkerson/Thrift-Client-Server-Example--PHP-。

I also blogged about how to implement a simple example with PHP and Python at http://willwarren.com/2012/01/24/creating-a-public-api-with-apache-thrift/

我还在http://willwarren.com/2012/01/24/creating-a-public-api-with-apache-thrift/上写了关于如何使用PHP和Python实现一个简单示例的博客