douliandan7340 2013-08-19 04:19
浏览 31
已采纳

如何使用go的net / http包提供php文件?

I want to a write a simple net/http.HandlerFunc which serves php files. Should I use net/http/cgi or net/http/fcgi, or is there a better way of running a php process?

  • 写回答

2条回答 默认 最新

  • doufeinai6081 2013-08-19 08:49
    关注

    From http://golang.org/pkg/net/http/fcgi/:

    Currently only the responder role is supported.

    The Go FCGI package does not support calling other processes. It only knows how to serve requests when another server (such as nginx) connects. Therefore, your only option is CGI.


    CGI is very inefficient and you should probably never use it. Instead, I recommend putting both your Go program and your PHP FCGI program behind a single reverse proxy such as Nginx.

    Nginx has many great features including keep-alive timeouts that the default Go http server do not support. Using a reverse proxy adds features to your Go program and allows you to integrate other languages as well.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制