1

我第一次在我的新 VPS 上设置了一个网络堆栈。我的目标是 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. 清洁 Debian 8.0 Jessie 安装
  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以处理带有我的新副本的 .sh 和 .rc 文件/newbin

澄清一下,第 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,我很想听听。

非常感谢!

4

0 回答 0