在Go中使用PHP。FastCGI?

huangapple go评论103阅读模式
英文:

PHP in Go. FastCGI?

问题

我正在使用Go编写一个将替代现有网站的Web服务器。我仍然需要一些旧的PHP脚本。现在我使用的是lighttpd + fastcgi。所以我希望我的Web服务器能够将PHP作为FastCGI调用。

处理这个问题的最佳方法是什么?
我猜我需要一些Go FastCGI API。

http://golang.org/pkg/net/http/fcgi/ - 看起来只支持服务器端而不是客户端。

英文:

I am writing webserver in Go that will replace existing website. I still need some old PHP scripts. Right now I have lighttpd + fastcgi. So I wish my web server to call PHP as FastCGI.

What is best way to handle it?
I guess I need some Go FastCGI API

http://golang.org/pkg/net/http/fcgi/ - It seems only to support Server side not client.

答案1

得分: 3

我认为如果你想直接连接到一个fastcgi进程,你需要自己创建一个。但要记住,你仍然需要运行一个进程管理器/生成器,所以运行nginx并让你的Go进程在那里代理PHP脚本也不是一个很大的跳跃。

你也可以合理地将其反过来,让最终用户连接到端口80上的nginx,并让nginx根据需要代理请求到你的Go进程或fastcgi。其中一个优点是,这样可以很容易地让Go进程以不同于root的用户身份运行。

英文:

I think you'd have to make your own if you want to connect directly to a fastcgi process. Keep in mind though that you still have to run a process manager/spawner anyway, so it wouldn't be a huge leap to just run nginx, too, and have your Go process proxy there for the PHP scripts.

You could also reasonably turn it around and have end-users connect to nginx on port 80 and have nginx proxy requests to your Go process or fastcgi as appropriate. One advantage of that is that then easily can have the Go process run as a different user than root.

huangapple
  • 本文由 发表于 2013年4月13日 21:18:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/15988225.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定