WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: lighttpd on RPi (with SSL)  (Read 191 times)

Offline Spike

  • Newbie
  • *
  • Posts: 7
lighttpd on RPi (with SSL)
« on: August 01, 2026, 10:05:52 AM »
Back in 2015 I built a Pi-based http server for a non-internet connected project using piCore and lighttpd.

I now need to update it to support SSL (https).  I don't really mind whether I go to a new version of piCore, but on balance I might as well do so while I'm making changes.

I have two problems:

1. lighttpd no longer seems to be in the extensions repository.  Is there a reason for this?

2. If I install lighttpd from an 11 year old repository, it seems to work, but as far as I can tell, that version (of lighttpd) doesn't support SSL.

Any thoughts as to where to go from here?  I guess I could switch to Apache, but I preferred the idea of a lighter-weight http server.

Offline patrikg

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 859
Re: lighttpd on RPi (with SSL)
« Reply #1 on: August 01, 2026, 10:16:17 AM »
How about nginx ?

Offline mjmouse

  • Newbie
  • *
  • Posts: 14
Re: lighttpd on RPi (with SSL)
« Reply #2 on: August 01, 2026, 10:30:07 AM »
I do have this build script sitting around. It expects to be run from the root of an extracted tarball of lighttpd. You will probably want to add extra flags to the ./configure call if you are needing a different ssl library. Also, since this was for tinycore x86_64, some of the libraries may be named differently.

(My main use for this was under x86_64, the lighttpd in the repos didn't have magnet support. I haven't tested the ssl support, since I already have it behind nginx)

Code: [Select]
tce-load -i compiletc autoconf automake libtool m4 pcre pcre-dev pkg-config libtool-dev
tce-load -i pcre21042-dev
tce-load -i lua-5.4-dev openssl-dev zstd-dev squashfs-tools sqlite3-dev libxml2-dev

if ! [ -e configure ]; then
libtoolize
./autogen.sh
fi

./configure --with-lua --with-zlib --with-zstd --with-bzip2 --with-openssl  --with-sqlite --with-webdav-props --with-webdav-locks --libdir=/usr/local/lib/lighttpd

make -j 4

make DESTDIR=/home/tc/lighttpd/lighttpd-m install
cd /home/tc/lighttpd

mksquashfs lighttpd-m lighttpd-m.tcz

cat <<EOF >lighttpd-m.tcz.dep
openssl.tcz
pcre21042.tcz
lua-5.4-lib.tcz
sqlite3.tcz
libxml2.tcz
EOF

Offline Spike

  • Newbie
  • *
  • Posts: 7
Re: lighttpd on RPi (with SSL)
« Reply #3 on: August 01, 2026, 11:44:54 AM »
Thanks, both.  I'll try building lighttpd using mjmouse's script.  If I don't get on well with that (haven't compiled *anything* on *nix in the last 30 years, never mind a tcx  :) ) I'll switch to nginx.  Though everything I read says how well suited lighttpd is for embedded systems and RPi, so let's hope that works out.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 12933
Re: lighttpd on RPi (with SSL)
« Reply #4 on: August 01, 2026, 01:02:58 PM »
Hi Spike
... mind a tcx  :) ...
Building a  .tcz  file is easy.

Install squashfs-tools.tcz:
Code: [Select]
tce-load -wi squashfs-tools
Create the directory tree that will contain the programs files:
Code: [Select]
mkdir -p pkg/usr/local/sbin
mkdir -p pkg/usr/local/lib
 ... etc ...

Copy (or move) the compiled files (or directories) to their destination:
Code: [Select]
cp -a Path/To/lighttpd pkg/usr/local/sbin
 ... etc ...

Once all of the required files have been copied, create the  .tcz  file:
Code: [Select]
mksquashfs pkg lighttpd.tcz -noappend

Offline Spike

  • Newbie
  • *
  • Posts: 7
Re: lighttpd on RPi (with SSL)
« Reply #5 on: August 02, 2026, 12:50:07 PM »
So building a tcz turned out to be not scary at all ;)

I managed to build lighttpd from the latest sources, and produced .tcz, .tcz.dep etc.  But when I try to load that onto a clean piCore 16.0, it says it's installed, but I'm not seeing a config file where I'd expect, i.e. /usr/local/etc/lighttpd/lighttpd.conf.

I'll continue poking around to see if I can see what I'm missing, but if anyone can point me in the right direction, I'd be grateful.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 12933
Re: lighttpd on RPi (with SSL)
« Reply #6 on: August 02, 2026, 03:58:50 PM »
Hi Spike
... but I'm not seeing a config file where I'd expect, i.e. /usr/local/etc/lighttpd/lighttpd.conf. ...

When you executed this step:
... Create the directory tree that will contain the programs files:
Code: [Select]
mkdir -p pkg/usr/local/sbin
mkdir -p pkg/usr/local/lib
 ... etc ...
...

Did you also do this:
Code: [Select]
mkdir -p pkg/usr/local/etc/lighttpdand copy a  lighttpd.conf  to that directory?

If you run:
Code: [Select]
unsquashfs -ll lighttpd.tczdoes the listing it prints out include  usr/local/etc/lighttpd/lighttpd.conf ?

Offline mjmouse

  • Newbie
  • *
  • Posts: 14
Re: lighttpd on RPi (with SSL)
« Reply #7 on: August 02, 2026, 05:14:53 PM »
It doesn't create a sample lighttpd.conf by default. I think that is more often a distro-provided thing.

It should be fine to just run
Code: [Select]
sudo lighttpd -D -f /path/to/a/new/lighttpd.conf once you make a new lighttpd.conf. And then remove -D once you are happy for it to run in the background.

Example (trimmed) contents of my config for my site: (it runs under an added www-data user)

Code: [Select]
server.document-root = "/home/www-data/repo/public_html/"
server.port = 80
server.username = "www-data"
server.groupname = "www-data"
static-file.exclude-extensions = ( ".php", ".cgi", ".lua" )
index-file.names = ( "index.html", "index.lua" )
mimetype.assign = (
   ".css"  => "text/css; charset=utf-8",
   ".html" => "text/html; charset=utf-8",
   ".js"   => "text/javascript; charset=utf-8",
   ".lua"  => "application/lua; charset=utf-8",
   ".png"  => "image/png",
   ".txt"  => "text/plain",
   ".webmanifest" => "application/manifest+json",
)
server.modules += ( "mod_cgi", "mod_status", "mod_access", "mod_accesslog", "mod_expire", "mod_redirect", "mod_setenv", "mod_magnet" )
magnet.attract-physical-path-to = ( "/home/www-data/repo/magnet.lua" )
magnet.attract-response-start-to = ( "/home/www-data/repo/magnet-response.lua" )
server.errorlog = "/tmp/lighttpd-error.log"
server.breakagelog = "/tmp/lighttpd-breakage.log"
accesslog.filename = "/tmp/lighttpd-access.log"

include_shell "echo var.lua = '\"'$(which lua)'\"'"
cgi.assign = ( ".lua" => var.lua )
cgi.execute-x-only = "enable"
cgi.limits = (
   "write-timeout" => 60,
   "read-timeout" => 180,
)
setenv.add-environment = (
   "REALDB_ROOT" => "/home/www-data/databases",
)
$HTTP["url"] =~ "^/favicon.ico$" {
   url.redirect = (
      "^/favicon.ico$" => "/favicon.png"
   )
   url.redirect-code = 307
}
# various basically-static data
$HTTP["url"] =~ "^/scripts/" {
   expire.url = ( "" => "access plus 30 days" )
}
$HTTP["url"] =~ "^/(main|clock)\.[0-9]+\.css$" {
   expire.url = ( "" => "access plus 30 days" )
}
$HTTP["url"] =~ "^/favicon\.(png|ico)$" {
   expire.url = ( "" => "access plus 30 days" )
}

Offline Spike

  • Newbie
  • *
  • Posts: 7
Re: lighttpd on RPi (with SSL)
« Reply #8 on: Today at 12:31:02 PM »
Ah, I see now.  My misunderstanding.

The original (from 2015) lighttpd that I installed from the piCore repository included a sample conf file, so I was expecting the build process to include one too.  I now see that's a separate step outside of the build itself.

Also, I'd created a script back then that took the conf file as installed by the tcz and edited it to add the bits that I needed.  So I think I'd got fixated on needing a conf file to use as a starting point, plus also worried that if the conf file was missing, maybe other things were missing too.

So, looks like I'm ready to go now.  Thanks again for your help.