paulgorman.org/technical

LXC container with Alpine Linux, lighttpd, and fcgi

--- bava ~ # lxc-create -n alpine-lighttpd -t alpine -- -r v3.5
--- bava ~ # lxc-console -n alpine-lighttpd
Connected to tty 1
alpine-lighttpd login: root
Welcome to Alpine!

~ # cat << EOF > ~/.profile

export PS1=‘— \h \w \$ ’ alias l=‘ls’ alias ll=‘ls -lh’ alias la=‘ls -a’ EOF ~ # exit — bava ~ # lxc-console -n alpine-lighttpd Connected to tty 1 alpine-lighttpd login: root Welcome to Alpine!

--- alpine-lighttpd ~ # apk update
--- alpine-lighttpd ~ # apk add lighttpd fcgi lua5.3
--- alpine-lighttpd ~ # rc-update add lighttpd default
--- alpine-lighttpd ~ $ rc-service lighttpd start

The container is about 15MB at this point.

Uncomment these lines in /etc/lighttpd/lighttpd.conf:

"mod_alias",
include "mod_cgi.conf"

Edit the file types in /etc/lighttpd/mod_cgi.conf:

    cgi.assign = (
            ".sh"  => "/bin/sh",
            ".lua" => "/usr/bin/lua5.3"
    )

And:

--- alpine-lighttpd ~ $ mkdir -p /var/www/localhost/cgi-bin/
--- alpine-lighttpd ~ $ cat << EOF > /var/www/localhost/cgi-bin/hello.sh

#!/bin/bash echo “Content-type: text/html” echo “” echo ‘’ echo ‘

Hello, CGI!

’ echo ‘’ exit 0 EOF — alpine-lighttpd ~ $ chmod a+x /var/www/localhost/cgi-bin/hello.sh — alpine-lighttpd ~ $ rc-service lighttpd restart

https://wiki.alpinelinux.org/wiki/Setting_Up_Lighttpd_With_FastCGI https://paulgorman.org/technical/linux-alpine.txt https://paulgorman.org/technical/linux-lxc.txt