操作
CGI 操作指南¶
lighttpd 2.0 不直接支持运行 CGI 脚本/二进制文件(它是一个“非派生”的 Web 服务器);因此您需要在 CGI 应用程序周围添加一个 FastCGI 包装器(有时您只是不想或无法将它们转换为真正的 FastCGI 应用程序)。
为此,一个包装器是 https://redmine.lighttpd.ac.cn/projects/fcgi-cgi/repository。
Lighttpd 配置¶
只需将 CGI 请求转发到您的 FastCGI 包装器
setup { module.load ( "mod_fastcgi" ); } alias ("/cgi-bin/" => "/usr/lib/cgi-bin"); if req.path =^ "/cgi-bin" { index ( "index.cgi", "index.pl", "index.html" ); if phys.path =~ "\.(cgi|pl)$" { if phys.is_file { fastcgi "unix:/var/run/lighttpd/sockets/www-cgi.sock"; } } }
生成 FastCGI CGI 包装器¶
一个简单的 ./run 脚本,用于通过 spawn-fcgi 和 runit/daemontools 启动 Rails 应用程序
#!/bin/sh exec 2>&1 exec /usr/bin/spawn-fcgi -n -s /var/run/lighttpd/sockets/www-cgi.sock -u nobody -U www-data -- /usr/bin/fcgi-cgi