InstallFromSource » History » Revision 28

Revision 27 (gstrauss, 2021-07-17 06:20) → Revision 28/35 (gstrauss, 2021-08-27 20:52)


 h2. InstallFromSource 

 h3. source browser 

 View source code in the "lighttpd 1.4 git repository":// 

 h3. source checkout 

 There are multiple options to obtain a lighttpd source tree.    git is recommended. 

 * git: (recommended) 
 read-only: @$ git clone 
 developer: @$ git clone git+ssh:// 
 # initial checkout 
 git clone 
 cd lighttpd1.4 
 # subsequent updates (to obtain latest source) 
 #cd lighttpd1.4 
 git pull 
 * svn: (alternative to git) 
 # initial checkout 
 svn checkout lighttpd1.4 
 cd lighttpd1.4 
 # subsequent updates (to obtain latest source) 
 #cd lighttpd1.4 
 svn update 
 * source release/snapshot 
 # download and extract tarball 
 latest=$(curl -s 
 curl -o "$latest.tar.xz""$latest.tar.xz" 
 tar -xJf "$latest.tar.xz" 
 cd $latest 

 h3. build prerequisites 

 lighttpd supports multiple build frameworks: automake, cmake, meson, and scons. 

 Ensure you have installed the latest development tools and packages available, e.g. for automake: 
 * autoconf 
 * automake 
 * libtool 
 * m4 

 A minimal lighttpd build typically leverages PCRE and pkg-config  
 * pcre-devel / libpcre3-dev 
 * pkg-config 

 Optional lighttpd modules may require one or more additional libraries, e.g. choices among TLS modules 
 * openssl 
 * gnutls 
 * mbedtls 
 * nss 
 * wolfssl 

 Further details can be found in "lighttpd INSTALL"://    *(Please read)* 
 Depending on which features you want, other development libraries may be needed: [[OptionalLibraries]] 
 On most systems you need to install the development version of the library packages; the library itself will not be enough! 
 On debian you can also use apt-get to install all lighttpd build dependencies: @apt-get build-dep lighttpd@ 

 h3. build commands (examples) 

 #cd lighttpd1.4 
 ./configure -C --prefix=/usr/local    # ./configure --help for additional options 
 make -j 4 
 make check 
 #sudo make install 
 #cd lighttpd1.4 
 cmake -DCMAKE_INSTALL_PREFIX=/usr/local -Wno-dev . 
 make -j 4 
 make test 
 #sudo make install 
 #cd lighttpd1.4 
 meson setup --buildtype debugoptimized --prefix /usr/local build 
 cd build 
 meson compile 
 meson test 
 #sudo meson install 
 #cd lighttpd1.4 
 scons -j 4 build_static=1 build_dynamic=0 prefix=/usr/local 
 #sudo scons -j 4 build_static=1 build_dynamic=0 prefix=/usr/local install 
 Examples commands for more fully-featured builds might reference "lighttpd scripts/":// 
 Also, there are more options for [[RunningUnitTests|running unit tests]] 

 h3. cross-compiling 

 automake help: @./configure --help@ 
 automake example: @./configure --build=arm-linux --host=x86_64-pc-linux-gnu --prefix=/usr/local --disable-static --enable-shared@ 

 "How-To: build lighttpd for iOS on arm64": 

 h3. distro packaging (external examples) 

 Debian: "debian/control": 
 Fedora: "lighttpd.spec": 
 OpenWRT: "net/lighttpd/Makefile": 

 h3. running lighttpd from build tree 

 lighttpd can be run from the build tree, without needing to install it.    This is useful for testing.    In the shell in which you built lighttpd, chdir to the top of the source tree (if not already there). 
 Create a basic lighttpd.conf to listen on localhost port 8080 and serve files from @/tmp@ (not recommended for production use!): 
 server.document-root = "/tmp" 
 server.bind = "" 
 server.port = 8080 
 mimetype.assign = (".txt" => "text/plain", ".html" => "text/html" ) 
 Create a simple file to serve: @echo "Hello World!" > /tmp/hello.txt@ 
 Run lighttpd in the foreground: @src/lighttpd -D -f lighttpd.conf -m $PWD/src/.libs@ 
 In a different shell: @curl 
 In the shell running lighttpd, press press @Ctrl-C@ to cause lighttpd to exit. 

 h3. signals 

 lighttpd responds to the following signals: 

 * SIGTERM - shut down immediately (terminate existing connections, then exit) 
 * SIGINT    - shut down gracefully    (serve existing connections, then exit) 
 * SIGUSR1 - reload gracefully       (serve existing connections, then reload config) 
 * SIGHUP    - re-open log files       (NOTE: does not reload lighttpd configuration) 

 (Note: SIGUSR1 behavior is available in lighttpd 1.4.46 and later) 

 h3. graceful restart 

 With lighttpd 1.4.46 and later, SIGUSR1 is the recommended method to gracefully handle configuration reloads, though a graceful stop and then restart of lighttpd is still required for lighttpd configurations which chroot. 

 With lighttpd 1.4.56 and later, graceful restart can have a time limit applied to existing active connections before the server reloads the config: ([[Server_feature-flagsDetails|server.feature-flags]]) 
 @server.feature-flags = ( "server.graceful-shutdown-timeout" => 5 )@ 
 In some configurations, lighttpd can immediately restart, while a forked copy of the server continued to serve existing connections (YMMV): 
 @server.feature-flags = ( "server.graceful-shutdown-timeout" => 5, "server.graceful-restart-bg" => "enable" )@ 
 @server.systemd-socket-activation = "enable"@ 

 archive: older article from 2005 talks about graceful restart using SIGINT: 

 h3. initscripts 

 Depending on the operating system and distribution brand, there are many ways to set up lighttpd to run as a daemon when the system starts up, and to send signals to lighttpd for start/stop/restart/etc.    Rather than attempting to maintain scripts for an unknown number of distros, here are links to a few, which can be used as examples. 

 * Arch: 
 * Debian: 
 * Fedora: 
 * Gentoo: 
 * openSUSE: 
 * OpenWRT: 

 sample systemd unit script "lighttpd.service": 

 h3. supervise 

 As an alternative to init scripts you can setup a "supervised" lighttpd with daemontools or runit, see [[LighttpdUnderSupervise]]