设置lighttpd + werc,CGI无法运行rc脚本?

时间:2015-07-14 07:03:19

标签: debian cgi lighttpd plan-9

我第一次在我的新VPS上设置了一个Web堆栈。我的目标是Debian Jessie + lighttpd + werc

werc是一个在rc上运行的简单框架(从Plan 9移植到Linux的非标准shell)。有一些教程可以让它在lighttpd上运行:

http://werc.cat-v.org/docs/quick-setup/debian-lighttpd

不幸的是,跟随他们是不成功的,我已经开始从基础CGI开始构建。我成功地让CGI使用sh脚本,但是当我试图让CGI使用rc时遇到了麻烦。我做了一些工作来分离问题,而且似乎lighttpd根本不会运行rc脚本。我很确定这不是权限或PATH问题;见下文。

总结我的设置:

  1. clean Debian 8.0 Jessie install
  2. 安装了lighttpd debian软件包
  3. 安装了9base-6以获取rc shell(http://tools.suckless.org/9base
  4. lighty-enable-mod cgi
  5. 在/ var / www / html / cgi-bin /中制作test.sh和test.rc脚本(见下文)
  6. 制作一个/newbin目录并将sh和rc的副本放入。
  7. 使用/etc/lighttpd/conf-enabled/10-cgi.conf
  8. 中的新副本编辑/newbin以处理.sh和.rc文件

    澄清一下,第6步是隔离问题所以我知道这不是PATH问题。

    这是一个shell会话,显示我的设置的所有组件,并记录我的问题:

    root@x220-jessie:~# cat /etc/lighttpd/lighttpd.conf 
    server.modules = (
        "mod_access",
        "mod_alias",
        "mod_compress",
        "mod_redirect",
    #       "mod_rewrite",
    )
    
    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
    
    
    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"
    
    root@x220-jessie:~# cat /etc/lighttpd/conf-enabled/10-cgi.conf 
    # /usr/share/doc/lighttpd/cgi.txt
    
    server.modules += ( "mod_cgi" )
    
    $HTTP["url"] =~ "^/cgi-bin/" {
        cgi.assign = ( ".rc" => "/newbin/rc" )
        cgi.assign += ( ".sh" => "/newbin/sh" )
    }
    
    root@x220-jessie:~# ls -l /newbin
    total 1128
    -rwxr-xr-x 1 root root 1024920 Jul 13 12:07 rc
    -rwxr-xr-x 1 root root  125400 Jul 13 12:11 sh
    root@x220-jessie:~# cat /var/www/html/cgi-bin/test.sh
    #!/bin/sh
    echo 'Content-Type: text/plain'
    echo
    echo 'This is a sh program!'
    root@x220-jessie:~# cat /var/www/html/cgi-bin/test.rc
    #!/newbin/rc
    echo 'Content-Type: text/plain'
    echo
    echo 'This is a rc program!'
    root@x220-jessie:~# /var/www/html/cgi-bin/test.sh
    Content-Type: text/plain
    
    This is a sh program!
    root@x220-jessie:~# /var/www/html/cgi-bin/test.rc
    Content-Type: text/plain
    
    This is a rc program!
    root@x220-jessie:~# /etc/init.d/lighttpd force-reload
    [ ok ] Reloading lighttpd configuration (via systemctl): lighttpd.service.
    root@x220-jessie:~# curl localhost | tail
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  3373  100  3373    0     0   872k      0 --:--:-- --:--:-- --:--:-- 1097k
      </p>
      <p>
       If you find a bug in this Lighttpd package, or in Lighttpd itself, please file a bug report on it. Instructions on doing this, and the list of known bugs of this package, can be found in the 
       <a href="http://bugs.debian.org/cgi-bin/pkgreport.cgi?pkg=lighttpd">Debian Bug Tracking System.</a>
      </p>
     </div>
    </div>
    <!-- s:853e9a42efca88ae0dd1a83aeb215047 -->
    </body>
    </html>
    root@x220-jessie:~# curl localhost/cgi-bin/test.sh
    This is a sh program!
    root@x220-jessie:~# curl localhost/cgi-bin/test.rc
    <?xml version="1.0" encoding="iso-8859-1"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
             "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
     <head>
      <title>500 - Internal Server Error</title>
     </head>
     <body>
      <h1>500 - Internal Server Error</h1>
     </body>
    </html>
    root@x220-jessie:~# tail /var/log/lighttpd/error.log 
    2015-07-13 12:48:40: (server.c.1558) server stopped by UID = 0 PID = 1 
    2015-07-13 12:51:14: (log.c.164) server started 
    2015-07-13 12:51:47: (server.c.1558) server stopped by UID = 0 PID = 1 
    2015-07-13 12:52:17: (log.c.164) server started 
    2015-07-13 12:52:31: (server.c.1558) server stopped by UID = 0 PID = 1 
    2015-07-13 12:52:42: (log.c.164) server started 
    2015-07-13 12:55:08: (server.c.1558) server stopped by UID = 0 PID = 1 
    2015-07-13 15:23:49: (log.c.164) server started 
    2015-07-13 15:25:49: (server.c.1558) server stopped by UID = 0 PID = 1 
    2015-07-13 15:25:50: (log.c.164) server started 
    root@x220-jessie:~# 
    

    我在运行Debian 8.0的VPS,运行Debian 8.0的笔记本电脑和运行Debian 7.8的笔记本电脑上遇到了同样的问题。

    我试图通过启动调试来进一步跟踪问题,但server.modules += ( "mod_debug" )导致lighttpd失败。如果有人就如何加快调试提出建议,那也是一种帮助。此外,如果有人碰巧尝试这个并成功在Debian 8.0上运行werc,我很乐意听到它。

    非常感谢!

0 个答案:

没有答案