【问题标题】:What is the correct Lighttpd configuration for a daemon implementing FastCGI++ library?实现 FastCGI++ 库的守护程序的正确 Lighttpd 配置是什么?
【发布时间】:2017-01-26 11:44:59
【问题描述】:

(也发布到 FastCGI++-users 邮件列表,但是它在很长一段时间内都没有活动)

我目前正在尝试在我正在编写的应用程序中使用 FastCGI++(2.1 版)库。该应用程序将作为 linux 机器上的守护进程运行,并通过 lighttpd 提供状态网页。我打算使用 FastCGI++ 接口定期自动更新状态网页。

我已经开始向我的应用程序添加一个线程,该线程创建一个 FastCGI++ 管理器的实例,并回显一个字符串文字以响应任何请求(与 Hello World 示例基本相同)。

但是,我似乎无法在浏览器中访问它,并且我怀疑我错误地配置了 lighttpd fastcgi 模块(/etc/lighttpd/lighttpd.conf 包含在下面)。 lighttpd错误日志记录了“unix上没有这样的文件或目录:/tmp/Myapp.sock”。

将 lighttpd 配置为与实现 fastcgi++ 库的守护进程接口的正确方法是什么?是否有必要使用 spawn-fcgi 启动守护进程?

谢谢,

迈克

cat /etc/lighttpd/lighttpd.conf:

server.modules = (
    "mod_access",
    "mod_alias",
    "mod_compress",
    "mod_redirect",
        "mod_rewrite",
    "mod_cgi",
    "mod_fastcgi",
)

server.document-root        = "/var/www/html"
server.upload-dirs          = ( "/var/cache/lighttpd/uploads" )
server.errorlog             = "/var/log/lighttpd/error.log"
server.pid-file             = "/var/run/lighttpd.pid"
server.username             = "www-data"
server.groupname            = "www-data"
server.port                 = 80

cgi.assign = (".py" => "/usr/bin/python3")
fastcgi.debug = 1
fastcgi.server = ( "/device" => (( 
                    "socket" => "/tmp/Myapp.sock",
                    "check_local" => "disable",
                    "docroot" => "/"
                ))
        )

index-file.names            = ( "index.php", "index.html", "index.lighttpd.html" )
url.access-deny             = ( "~", ".inc" )
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )

compress.cache-dir          = "/var/cache/lighttpd/compress/"
compress.filetype           = ( "application/javascript", "text/css", "text/html", "text/plain" )

# default listening port for IPv6 falls back to the IPv4 port
include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port
include_shell "/usr/share/lighttpd/create-mime.assign.pl"
include_shell "/usr/share/lighttpd/include-conf-enabled.pl"

【问题讨论】:

    标签: c linux lighttpd fastcgi++


    【解决方案1】:

    “unix 上没有这样的文件或目录:/tmp/Myapp.sock”

    这意味着套接字丢失了。

    你的守护进程正在运行吗?你启动了吗?

    如果您希望 lighttpd 启动守护程序,那么您必须在“/device”的 fastcgi.server 设置中包含“bin-path”。看 https://redmine.lighttpd.net/projects/lighttpd/wiki/Docs_ModFastCGI

    【讨论】:

    • 守护进程正在运行。我的印象是,如果 lighttpd 启动应用程序,那么 (a) 每个请求都会创建一个新实例,并且 (b) 应用程序只会在请求期间运行。鉴于守护进程涉及特定硬件设备的监视和控制,我需要它从启动时一直运行。
    • 您的印象不正确。 lighttpd 在启动时启动守护进程,并在 lighttpd 关闭时向它发送一个术语信号。无论 lighttpd 是否启动守护进程,lighttpd 都会为每个请求创建一个到 FastCGI 后端的新套接字连接。如果守护程序正在运行,那么 /tmp/Myapp.sock 应该存在。可以?如果不是,cron 作业是否由于“旧”时间戳而将其从 /tmp 中删除?也许考虑把插座放在别处?
    猜你喜欢
    • 2017-02-11
    • 1970-01-01
    • 1970-01-01
    • 2021-04-01
    • 1970-01-01
    • 2020-03-04
    • 2011-06-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多