英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论