User Tools

Site Tools


software:lighttpd

This is an old revision of the document!


lighttpd

Lighttpd (AKA lighty) is a lightweight HTTP server written in C that specializes in low resource usage. Its configuration is powerful, but more terse than Apache and nginx. Due to lighty's focus on resource use, it has a variety of strategies for dealing with high resource use.

cgit

Create a new cgit-oriented file somewhere in your configuration hierarchy. Then be sure you're includeing it in lighttpd's main configuration file.

git.zlg.space.conf
server.name = "git.zlg.space"
server.document-root = var.basedir + "/cgit"
index-file.names = ( "cgit.cgi" )
cgi.assign = (
    "cgit.cgi" => ""
)
dir-listing.activate = "disable"
url.rewrite-once = (
        # Serve static files plainly
	"/(cgit.css|favicon.ico|cgit.png|robots.txt)" => "",
        # and let cgit handle the rest
        "" => "/cgit.cgi?url=${url.path}${qsa}"
        # If the above line doesn't work (lighty < 1.4.50), uncomment this one:
        #"^/([^?/]+/[^?]*)?(?:\?(.*))?$" => "/cgit.cgi?url=$1&$2"
)

I use /srv/www/cgit, with these symlinks:

cgit.cgi -> /usr/share/webapps/cgit/cgit.cgi
cgit.css -> /usr/share/webapps/cgit/cgit.css
cgit.png -> /usr/share/webapps/cgit/cgit.png

Your OS may do things differently; the above is where they're stored for Adélie Linux and Gentoo Linux.

Next, be sure you have the correct modules enabled. Additionally, you need to setup a temporary file space with permissions that allow the server to read and write to it. Highlighted source code view with cgit can be rather large, and lighttpd will switch to temporary files when a transfer of data is large enough.

/etc/lighttpd/lighttpd.conf
server,modules += ( "mod_cgi", "mod_dirlisting" )
# Change this to suit your needs:
server.upload-dirs = ( "/var/tmp/lighttpd" )
include "git.zlg.space.conf"

I chose /var/tmp/lighttpd, but it can be any storage you want. Just be sure that it's enough to have data written to it frequently, as needed. Be sure to setup /var/cache/cgit (or wherever else you configured it) as well.

mkdir -p /var/tmp/lighttpd /var/cache/cgit
chown lighttpd:lighttpd /var/tmp/lighttpd /var/cache/cgit

Next, setup your cgit config. The cgit package usually comes with /etc/cgitrc. You'll want to change the scan-path variable to point to wherever you plan on storing the repositories (I chose /srv/www/cgit), and make sure scan-path is the last line in cgitrc.

Lastly, start the server using whatever your OS uses to manage servers. For OpenRC:

rc-service lighttpd start
software/lighttpd.1543140460.txt.gz · Last modified: 2018-11-25 10:07 by zlg