Project

General

Profile

InstallFromSource » History » Revision 21

Revision 20 (ardhill, 2020-05-17 08:24) → Revision 21/38 (gstrauss, 2021-07-14 18:45)

{{>toc}} h1. InstallFromSource 

 h2. InstallFromSource 

 h3. source browser 

 View source code in Get the "lighttpd 1.4 git repository"://git.lighttpd.net/lighttpd/lighttpd1.4.git 


 h3. source checkout 

 There are multiple options to obtain You can either use a lighttpd source tree.    git is recommended. 

 * release from "www.lighttpd.net/download"://www.lighttpd.net/download or compile from git: (recommended) 
 read-only: @$ git clone https://git.lighttpd.net/lighttpd/lighttpd1.4.git@ * Using a release/snapshot: 
   Extract the tar ball and enter the new directory: 
   <pre> 
 developer: @$ git clone git+ssh://git@lighttpd.net/lighttpd/lighttpd1.4.git@ tar -xf lighttpd-1.4.XXX.tar.gz 
 <pre> cd lighttpd-1.4.XXX 
 # initial checkout </pre> 
 * git (you will need autoconf and automake for this): 
   First time: 
   <pre> 
 git clone https://git.lighttpd.net/lighttpd/lighttpd1.4.git 
 cd lighttpd1.4 
 # subsequent updates (to obtain latest source) ./autogen.sh 
 #cd lighttpd1.4 </pre> 
   Next time in @lighttpd1.4/@: 
   <pre> 
 git pull 
 ./autogen.sh 
 </pre> 
 * svn: (alternative to git) 
 <pre> 
 # instead of git you can also use svn, the initial checkout is created with: 
   <pre> 
 svn checkout https://github.com/lighttpd/lighttpd1.4/trunk lighttpd1.4 
 cd lighttpd1.4 
 # subsequent </pre> 
   And updates (to obtain latest source) will be fetched with the usual: 
   <pre> 
 #cd lighttpd1.4 
 svn update 
 </pre> 
 * source release/snapshot 
 https://www.lighttpd.net/download/ 
 https://download.lighttpd.net/lighttpd/ 
 <pre> 
 # download and extract tarball 
 latest=$(curl -s https://download.lighttpd.net/lighttpd/releases-1.4.x/latest.txt) 
 curl https://download.lighttpd.net/lighttpd/releases-1.4.x/$latest.tar.xz 
 tar -xJf $latest.tar.xz 
 cd $latest 
 </pre> 


 h3. build prerequisites 

 lighttpd supports multiple build frameworks: automake, cmake, meson, Also see [[DevelGit]] and scons. [[Devel]]. 

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

 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"://git.lighttpd.net/lighttpd/lighttpd1.4/src/branch/master/INSTALL    *(Please read)* 
 Depending on which features you want, you need other development libraries may be needed: [[OptionalLibraries]] libraries; you will want at least libpcre and zlib, for more see [[OptionalLibraries]]. 
 On most systems you need to install the development version of the library packages; packages, the library itself will not won't be enough! 
 

 On debian you can also use apt-get to install all lighttpd build dependencies: @apt-get 
 <pre> 
 apt-get build-dep lighttpd@ 


 h3. build commands (examples) lighttpd 
 </pre> 

 automake h2. Configure 

 Now you have to use the @./configure@ script - there is a help option for it: 
 <pre> 
 #cd lighttpd1.4 
 ./autogen.sh 
 ./configure -C --prefix=/usr/local    # ./configure --help for additional options 
 make -j 4 
 make check 
 #sudo make install 
 </pre> 
 cmake 
 <pre> 
 #cd lighttpd1.4 
 cmake -DCMAKE_INSTALL_PREFIX=/usr/local -Wno-dev . 
 make -j 4 
 make test 
 #sudo make 

 Don't forget to set the @--prefix@ if you don't want to install 
 </pre> 
 meson 
 <pre> 
 #cd lighttpd1.4 
 meson setup --prefix /usr/local in /usr/local. 

 h2. Build 

 If the configure step was successful, you can now build it: 
 cd build 
 meson compile 
 meson test 
 #sudo meson install 
 </pre> 
 scons 
 <pre> 
 #cd lighttpd1.4 make 
 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 
 </pre> 
 Examples commands for more fully-featured builds might reference "lighttpd scripts/ci-build.sh"://git.lighttpd.net/lighttpd/lighttpd1.4/src/branch/master/scripts/ci-build.sh 
 Also, there are more options for [[RunningUnitTests|running unit tests]] 


 h3. distro packaging (external examples) 

 Debian: "debian/control":https://salsa.debian.org/debian/lighttpd/-/blob/master/debian/control 
 Fedora: "lighttpd.spec":https://src.fedoraproject.org/rpms/lighttpd/blob/rawhide/f/lighttpd.spec 
 OpenWRT: "net/lighttpd/Makefile":https://github.com/openwrt/packages/blob/master/net/lighttpd/Makefile 


 h3. running lighttpd from build tree h2. Install 

 lighttpd can be run from the After a successful build tree, without needing to you may install it.    the package. This is useful for testing.    In the shell in which not needed, but you built lighttpd, chdir will have to give lighttpd the top correct location of the source tree (if not already there). modules if you don't (see ./lighttpd -h). 
 Create a basic lighttpd.conf As you hopefully didn't use root to listen on localhost port 8080 and serve files from @/tmp@ (not recommended for production use!): build the package, you probably have now to get root access: 
 <pre> 
 server.document-root = "/tmp" su make install 
 server.bind = "127.0.0.1" 
 server.port = 8080 
 mimetype.assign = (".txt" => "text/plain", ".html" => "text/html" ) 
 </pre> 
 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 http://127.0.0.1:8080/hello.txt@ 
 In the shell running lighttpd, press press @Ctrl-C@ to cause lighttpd to exit. 


 h3. 

 h2. 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. 

 h2. graceful restart 

 https://blog.lighttpd.net/articles/2005/09/02/graceful-restart/ 
 The current recommended way to reload lighttpd config is to gracefully stop and then to restart lighttpd. 

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


 h3. 

 h2. 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: https://git.archlinux.org/svntogit/packages.git/tree/trunk?h=packages/lighttpd 
 * Debian: https://salsa.debian.org/debian/lighttpd 
 * Fedora: http://pkgs.fedoraproject.org/cgit/rpms/lighttpd.git/tree/ 
 * Gentoo: https://gitweb.gentoo.org/repo/gentoo.git/tree/www-servers/lighttpd/files 
 * openSUSE: https://build.opensuse.org/package/show/server:http/lighttpd 

 sample systemd unit script "lighttpd.service":https://redmine.lighttpd.net/projects/lighttpd/repository/revisions/master/entry/doc/systemd/lighttpd.service 


 h3. supervise 

 h2. Supervise 

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