I'm setting up a web stack for the first time on my new VPS. My goal is Debian Jessie + lighttpd + werc
werc is a simple framework that runs on rc (a nonstandard shell ported to Linux from Plan 9). There are some tutorials to get it working on lighttpd:
http://werc.cat-v.org/docs/quick-setup/debian-lighttpd
Unfortunately, following them was unsuccessful and I've started the process of building up starting at basic CGI. I successfully got CGI working with sh scripts, but ran into trouble when I tried to get CGI working with rc. I did a little bit of work to isolate the issue, and it appears that lighttpd simply won't run rc scripts. I'm pretty sure it's not permissions or a PATH issue; see below.
To summarize my setup:
- clean Debian 8.0 Jessie install
- installed lighttpd debian package
- installed 9base-6 to get the rc shell (http://tools.suckless.org/9base)
- lighty-enable-mod cgi
- make test.sh and test.rc scripts in /var/www/html/cgi-bin/ (see below)
- make a
/newbindirectory and put copies of sh and rc in. - edit
/etc/lighttpd/conf-enabled/10-cgi.confto handle .sh and .rc files with my new copies in/newbin
To clarify, step 6 is to isolate the problem so I know it's not a PATH issue.
Here's a shell session showing all the components of my setup, and documenting my problem:
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:~#
I've run into the same problem on my VPS running Debian 8.0, my laptop running Debian 8.0, and my laptop running Debian 7.8.
I've tried to track the problem down further by cranking up the debugging, but server.modules += ( "mod_debug" ) caused lighttpd to fail. If anyone has suggestions on how to crank up debugging, that would be a help too. Also if anyone happens to try this and succeeds in running werc on Debian 8.0, I'd love to hear about it.
Thanks a bunch!