<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Gstrauss</id>
	<title>Alpine Linux - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Gstrauss"/>
	<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/wiki/Special:Contributions/Gstrauss"/>
	<updated>2026-05-04T03:35:13Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.40.0</generator>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Production_Web_server:_Lighttpd&amp;diff=25426</id>
		<title>Production Web server: Lighttpd</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Production_Web_server:_Lighttpd&amp;diff=25426"/>
		<updated>2023-11-02T03:22:27Z</updated>

		<summary type="html">&lt;p&gt;Gstrauss: simplify TLS config; prefer modern lighttpd TLS defaults&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
[https://www.lighttpd.net/ lighttpd] is a simple, standards-compliant, secure, and flexible web server. &lt;br /&gt;
&lt;br /&gt;
== Lighttpd Installation ==&lt;br /&gt;
&lt;br /&gt;
This production environment will handle only the necessary packages... so no doc or manpages allowed.&lt;br /&gt;
&lt;br /&gt;
# make the htdocs public web root directories &lt;br /&gt;
# added the service to the default runlevel, not to boot, because need networking activated&lt;br /&gt;
# start the web server service&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;&lt;br /&gt;
mkdir -p /var/www/localhost/htdocs /var/log/lighttpd /var/lib/lighttpd&lt;br /&gt;
&lt;br /&gt;
chown -R lighttpd:lighttpd /var/www/localhost/ /var/log/lighttpd /var/lib/lighttpd &lt;br /&gt;
&lt;br /&gt;
rc-update add lighttpd default&lt;br /&gt;
&lt;br /&gt;
rc-service lighttpd restart&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;it works&amp;quot; &amp;gt; /var/www/localhost/htdocs/index.html&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;For testing, open a browser and go to &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;http://&amp;lt;webserveripaddres&amp;gt;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; and you will see &amp;quot;it works&amp;quot;&#039;&#039;&#039;. The &amp;quot;webserveripaddres&amp;quot; is the ip address of your setup/server machine.&lt;br /&gt;
&lt;br /&gt;
=== Controlling Lighttpd ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Start lighttpd&#039;&#039;&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|rc-service lighttpd start}}&lt;br /&gt;
&lt;br /&gt;
You will get feedback about the status.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 * Caching service dependencies                                 [ ok ]&lt;br /&gt;
 * Starting lighttpd...                                         [ ok ]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Stop lighttpd&#039;&#039;&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|rc-service lighttpd stop}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Restart lighttpd&#039;&#039;&#039;&#039;&#039;: After changing the configuration file, lighttpd needs to be restarted.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|rc-service lighttpd restart}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Proper Runlevel&#039;&#039;&#039;&#039;&#039;: By default no services are added to start process, sysadmin must know what we want and what will services do, also other main reason are due in dockers there&#039;s no runlevels per se and Alpine linux are mostly used in dockers containers. You must added the service only to the default runlevel, not to boot, because need networking activated&lt;br /&gt;
&lt;br /&gt;
{{Cmd|rc-update add lighttpd default}}&lt;br /&gt;
&lt;br /&gt;
== Lighttpd Configuration ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;If you just want to serve simple HTML pages, lighttpd can be used out-of-box. No further configuration needed.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
[https://wiki.lighttpd.net/Docs_ConfigurationOptions lighttpd configuration options]&lt;br /&gt;
&lt;br /&gt;
=== Status page ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Taking care of the status web server:&#039;&#039;&#039; those special pages are just minimal info of the running web server, are need to view from outside in a case of emergency, do not take the wrong approach of hide behind a filtered ip or filtered network, you must have access in all time in all the web to see problems.&lt;br /&gt;
&lt;br /&gt;
[https://wiki.lighttpd.net/mod_status mod_status]&lt;br /&gt;
&lt;br /&gt;
# Enable the mod_status at the config files&lt;br /&gt;
# change path in the config file (optional), we are using security by obfuscation&lt;br /&gt;
# restart the service to see changes at the browser&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;&lt;br /&gt;
sed -i -r &#039;s#\#.*mod_status.*,.*#    &amp;quot;mod_status&amp;quot;,#g&#039; /etc/lighttpd/lighttpd.conf&lt;br /&gt;
&lt;br /&gt;
sed -i -r &#039;s#.*status.status-url.*=.*#status.status-url  = &amp;quot;/stats/server-status&amp;quot;#g&#039; /etc/lighttpd/lighttpd.conf&lt;br /&gt;
&lt;br /&gt;
sed -i -r &#039;s#.*status.config-url.*=.*#status.config-url  = &amp;quot;/stats/server-config&amp;quot;#g&#039; /etc/lighttpd/lighttpd.conf&lt;br /&gt;
&lt;br /&gt;
rc-service lighttpd restart&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== CGI bin directory support ===&lt;br /&gt;
&lt;br /&gt;
By default packages assign a directory under localhost main domain, other linux uses a global cgi directory and aliasing.. the most professional way, but think about it, this per domain configuration allows isolation:&lt;br /&gt;
&lt;br /&gt;
[https://wiki.lighttpd.net/mod_cgi mod_cgi]&lt;br /&gt;
&lt;br /&gt;
# enable the mod_alias at the config file, due need of a specific path for cgi files into security&lt;br /&gt;
# create the directory&lt;br /&gt;
# enable the config cgi file&lt;br /&gt;
# restart the service to see changes at the browser&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;&lt;br /&gt;
mkdir -p /var/www/localhost/cgi-bin&lt;br /&gt;
&lt;br /&gt;
sed -i -r &#039;s#\#.*mod_alias.*,.*#    &amp;quot;mod_alias&amp;quot;,#g&#039; /etc/lighttpd/lighttpd.conf&lt;br /&gt;
&lt;br /&gt;
sed -i -r &#039;s#.*include &amp;quot;mod_cgi.conf&amp;quot;.*#   include &amp;quot;mod_cgi.conf&amp;quot;#g&#039; /etc/lighttpd/lighttpd.conf&lt;br /&gt;
&lt;br /&gt;
rc-service lighttpd restart&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After that, all the files under the &amp;lt;code&amp;gt;/var/www/localhost/cgi-bin&amp;lt;/code&amp;gt; directory will be accessed under &amp;lt;nowiki&amp;gt;http://localhost/cgi-bin/&amp;lt;/nowiki&amp;gt; path&lt;br /&gt;
&lt;br /&gt;
.cgi and .pl scripts are run using /usr/bin/perl.  Review and modify mod_cgi.conf others are needed.  Then restart lighttpd to pick up the changes.&lt;br /&gt;
&lt;br /&gt;
=== Make special errors (404 or 500) pages for clients and visitors ===&lt;br /&gt;
&lt;br /&gt;
These pages will be shown to visitors when a page or path is not present on the server, or when an internal error happens. &lt;br /&gt;
These replace the default, minimal error pages and can be a nice message or &amp;quot;away from here&amp;quot; message:&lt;br /&gt;
&lt;br /&gt;
[https://wiki.lighttpd.net/Server_errorfile-prefixDetails server.errorfile-prefix]&lt;br /&gt;
&lt;br /&gt;
# create the directory for put the html files to show when those errors occur&lt;br /&gt;
# create the simple files for each message in the directory&lt;br /&gt;
# set the proper in the configuration file&lt;br /&gt;
# restart the service to see the changes at the browser (just request a non existing page and you will see it)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;&lt;br /&gt;
mkdir -p /var/www/localhost/errors&lt;br /&gt;
&lt;br /&gt;
cat &amp;gt; /var/www/localhost/errors/status-404.html &amp;lt;&amp;lt; EOF&lt;br /&gt;
&amp;lt;h1&amp;gt;The page that you requested are not yet here anymore, sorry was moved or updated, search or visit another one&amp;lt;/h1&amp;gt;&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
cat &amp;gt; /var/www/localhost/errors/status-500.html &amp;lt;&amp;lt; EOF&lt;br /&gt;
&amp;lt;h1&amp;gt;Please wait a moment, there&#039;s something happens and we are give support maintenance right now to resolve&amp;lt;/h1&amp;gt;&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
cp /var/www/localhost/errors/status-404.html /var/www/localhost/errors/status-403.html&lt;br /&gt;
&lt;br /&gt;
cp /var/www/localhost/errors/status-500.html /var/www/localhost/errors/status-501.html&lt;br /&gt;
&lt;br /&gt;
cp /var/www/localhost/errors/status-500.html /var/www/localhost/errors/status-503.html&lt;br /&gt;
&lt;br /&gt;
sed -i -r &#039;s#.*server.errorfile-prefix.*#server.errorfile-prefix    = var.basedir + &amp;quot;/errors/status-&amp;quot;#g&#039; /etc/lighttpd/lighttpd.conf&lt;br /&gt;
&lt;br /&gt;
rc-service lighttpd restart&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Userdir public_html support ===&lt;br /&gt;
&lt;br /&gt;
[https://wiki.lighttpd.net/mod_userdir mod_userdir]&lt;br /&gt;
&lt;br /&gt;
== Lighttpd SSL support ==&lt;br /&gt;
&lt;br /&gt;
[https://wiki.lighttpd.net/Docs_SSL lighttpd TLS doc]&lt;br /&gt;
&lt;br /&gt;
Create TLS configuration for lighttpd.  Best way to do that is by external include files. Debian counterpart has a good mechanism that enables configuration files.  We will add SSL support in a similar way.&lt;br /&gt;
&lt;br /&gt;
=== SSL : making self signed certificate ===&lt;br /&gt;
&lt;br /&gt;
We need to created a self-signed certificate if we do not already have one:&lt;br /&gt;
&lt;br /&gt;
# install openssl&lt;br /&gt;
# create the self signed certificate&lt;br /&gt;
# set proper permissions&lt;br /&gt;
# create a SSL module configuration file for lighttpd&lt;br /&gt;
# activate the openssl module missing from config file&lt;br /&gt;
# activate the mod_redirect in case of global http to https redirections&lt;br /&gt;
# restart the service to see changes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;&lt;br /&gt;
apk add openssl&lt;br /&gt;
&lt;br /&gt;
mkdir -p /etc/ssl/certs/&lt;br /&gt;
&lt;br /&gt;
openssl req -x509 -days 1460 -nodes -newkey rsa:4096 \&lt;br /&gt;
   -subj &amp;quot;/C=VE/ST=Bolivar/L=Upata/O=VenenuX/OU=Systemas:hozYmartillo/CN=$(hostname -d)&amp;quot; \&lt;br /&gt;
   -keyout /etc/ssl/certs/$(hostname -d).pem -out /etc/ssl/certs/$(hostname -d).pem&lt;br /&gt;
&lt;br /&gt;
chmod 640 /etc/ssl/certs/$(hostname -d).pem&lt;br /&gt;
&lt;br /&gt;
cat &amp;gt; /etc/lighttpd/mod_ssl.conf &amp;lt;&amp;lt; EOF&lt;br /&gt;
server.modules += (&amp;quot;mod_openssl&amp;quot;)&lt;br /&gt;
\$SERVER[&amp;quot;socket&amp;quot;] == &amp;quot;0.0.0.0:443&amp;quot; {&lt;br /&gt;
    ssl.engine  = &amp;quot;enable&amp;quot;&lt;br /&gt;
    ssl.pemfile = &amp;quot;/etc/ssl/certs/$(hostname -d).pem&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
\$HTTP[&amp;quot;scheme&amp;quot;] == &amp;quot;http&amp;quot; {&lt;br /&gt;
    url.redirect = (&amp;quot;&amp;quot; =&amp;gt; &amp;quot;https://\${url.authority}\${url.path}\${qsa}&amp;quot;)&lt;br /&gt;
    url.redirect-code = 308&lt;br /&gt;
}&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
sed -i -r &#039;s#\#.*mod_redirect.*,.*#    &amp;quot;mod_redirect&amp;quot;,#g&#039; /etc/lighttpd/lighttpd.conf&lt;br /&gt;
&lt;br /&gt;
checkssl=&amp;quot;&amp;quot;;checkssl=$(grep &#039;include &amp;quot;mod_ssl.conf&#039; /etc/lighttpd/lighttpd.conf);[[ &amp;quot;$checkssl&amp;quot; != &amp;quot;&amp;quot; ]] &amp;amp;&amp;amp; echo listo || sed -i -r &#039;s#.*include &amp;quot;mime-types.conf&amp;quot;.*#include &amp;quot;mime-types.conf&amp;quot;\ninclude &amp;quot;mod_ssl.conf&amp;quot;#g&#039; /etc/lighttpd/lighttpd.conf&lt;br /&gt;
&lt;br /&gt;
rc-service lighttpd restart&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For deploy usage of Lets Encrypt without chain-tools (just add water) read [https://wiki.lighttpd.net/HowToSimpleSSL HowToSimpleSSL].&lt;br /&gt;
&lt;br /&gt;
== Lighttpd advanced ==&lt;br /&gt;
&lt;br /&gt;
Lighttpd has pretty good default settings, but a few might be tweaked if we need to respond to higher server loads.&lt;br /&gt;
&lt;br /&gt;
[https://wiki.lighttpd.net/Docs_ResourceTuning lighttpd resource tuning]&lt;br /&gt;
&lt;br /&gt;
=== Lighttpd tunning for aggressive load ===&lt;br /&gt;
&lt;br /&gt;
[https://wiki.lighttpd.net/Docs_Performance lighttpd performance tuning]&lt;br /&gt;
&lt;br /&gt;
=== More connections, More File Descriptors ===&lt;br /&gt;
&lt;br /&gt;
This must be used with caution.  Everything is a file to a UNIX operating system. Well, every time a visitor accesses a page, lighttpd uses three file descriptors: An IP socket to the client, a FastCGI process socket, and a filehandle for the document accessed. Lighttpd stops accepting new connections when 90% of the available sockets are in use, restarting again when usage has fallen to 80%. With the default setting of 1024 file descriptors, lighttpd can handle a maximum of 307 connections. If this number are exceded file descriptor must be increrased then. This are a delicate tune due must be check your default with &amp;lt;code&amp;gt;cat /proc/sys/fs/file-max&amp;lt;/code&amp;gt; and make sure it’s over 10,000:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;&lt;br /&gt;
checkset=&amp;quot;&amp;quot;;checkset=$(grep &#039;max-fds&#039; /etc/lighttpd/lighttpd.conf);[[ &amp;quot;$checkset&amp;quot; != &amp;quot;&amp;quot; ]] &amp;amp;&amp;amp; echo listo || sed -i -r &#039;s#server settings.*#server settings\nserver.max-fds = 2048\n#g&#039; /etc/lighttpd/lighttpd.conf&lt;br /&gt;
&lt;br /&gt;
rc-service lighttpd restart&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== HTTP Keep-Alive for aggressive load ===&lt;br /&gt;
&lt;br /&gt;
One reason that file descriptors get used up so quickly is HTTP keep-alive. To improve performance, modern web servers keep client connections alive to handle multiple requests instead of building up and tearing down connections for each item in a page. Keep-alive is tremendously beneficial to performance, but tends to keep unnecessary connections alive, too. lighttpd allows 1000 keep-alive requests per connection, allows idle sessions to remain alive for 5 seconds, and gives reads and writes 1 minute and 6 minutes to complete, respectively.&lt;br /&gt;
&lt;br /&gt;
# Maximum number of request within a keep-alive session before the server terminates the connection, default = 1000 (&amp;lt;code&amp;gt;server.max-keep-alive-requests&amp;lt;/code&amp;gt;)&lt;br /&gt;
# Maximum number of seconds until an idling keep-alive connection is dropped, default = 5 (&amp;lt;code&amp;gt;server.max-keep-alive-idle&amp;lt;/code&amp;gt;)&lt;br /&gt;
# Maximum number of seconds until a waiting, non keep-alive read times out and closes the connection, default = 60 (&amp;lt;code&amp;gt;server.max-read-idle&amp;lt;/code&amp;gt;)&lt;br /&gt;
# Maximum number of seconds until a waiting write call times out and closes the connection, default = 360 (&amp;lt;code&amp;gt;server.max-write-idle&amp;lt;/code&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
Although lighttpd has pretty aggressive defaults (especially compared to Apache), a period of heavy traffic and a few slow clients could see many unused connections sticking around. The server.max-keep-alive-idle setting default of 5 seconds can be reduced to as low as 2, if you assume your clients are reasonably quick about requesting data, but a value of 3 or 4 is probably realistic. You may want to increase the server.max-keep-alive-requests value from the default of 1000, but you probably don’t need to. The server.max-read-idle and server.max-write-idle settings are tempting targets, but these situations are usually fairly rare so let’s not monkey with them.&lt;br /&gt;
&lt;br /&gt;
=== Lighttpd_Advanced_security ===&lt;br /&gt;
&lt;br /&gt;
See at [[Lighttpd_Advanced_security]] wiki page.&lt;br /&gt;
&lt;br /&gt;
=== Lighttpd and PHP with fpm ===&lt;br /&gt;
&lt;br /&gt;
In production web, LAMP means &#039;&#039;&#039;L&#039;&#039;&#039;inux + &#039;&#039;&#039;A&#039;&#039;&#039;pache + &#039;&#039;&#039;M&#039;&#039;&#039;ysql + &#039;&#039;&#039;P&#039;&#039;&#039;hp installed and integrated, but today the &amp;quot;A&amp;quot; of apache are more used as Nginx or Lighttpd, and the &amp;quot;M&amp;quot; of MySQL are more used as Mariadb, the LAMP focused documents are:&lt;br /&gt;
&lt;br /&gt;
* LAMP deploy of the Web Server with PHP, user html_dir and MariaDB: [[Production LAMP system: Lighttpd + PHP + MySQL]]&lt;br /&gt;
&lt;br /&gt;
= See Also =&lt;br /&gt;
&lt;br /&gt;
* [[Production LAMP system: Lighttpd + PHP + MySQL]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Newbie]]&lt;br /&gt;
[[Category:Server]]&lt;br /&gt;
[[Category:Web_Server]]&lt;br /&gt;
[[Category:Monitoring]]&lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
[[Category:Security]]&lt;br /&gt;
[[Category:Production]]&lt;/div&gt;</summary>
		<author><name>Gstrauss</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Production_Web_server:_Lighttpd&amp;diff=22800</id>
		<title>Production Web server: Lighttpd</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Production_Web_server:_Lighttpd&amp;diff=22800"/>
		<updated>2022-12-22T17:55:57Z</updated>

		<summary type="html">&lt;p&gt;Gstrauss: Undo revision 22799 by Gstrauss (talk) backslases needed in shell command&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
[http://www.lighttpd.net/ lighttpd] is a simple, standards-compliant, secure, and flexible web server. &lt;br /&gt;
&lt;br /&gt;
== Lighttpd Installation ==&lt;br /&gt;
&lt;br /&gt;
This production environment will handle only the necessary packages... so no doc or manpages allowed.&lt;br /&gt;
&lt;br /&gt;
# make the htdocs public web root directories &lt;br /&gt;
# added the service to the default runlevel, not to boot, because need networking activated&lt;br /&gt;
# start the web server service&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;&lt;br /&gt;
mkdir -p /var/www/localhost/htdocs /var/log/lighttpd /var/lib/lighttpd&lt;br /&gt;
&lt;br /&gt;
chown -R lighttpd:lighttpd /var/www/localhost/ /var/log/lighttpd /var/lib/lighttpd &lt;br /&gt;
&lt;br /&gt;
rc-update add lighttpd default&lt;br /&gt;
&lt;br /&gt;
rc-service lighttpd restart&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;it works&amp;quot; &amp;gt; /var/www/localhost/htdocs/index.html&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;For testing, open a browser and go to &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;http://&amp;lt;webserveripaddres&amp;gt;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; and you will see &amp;quot;it works&amp;quot;&#039;&#039;&#039;. The &amp;quot;webserveripaddres&amp;quot; is the ip address of your setup/server machine.&lt;br /&gt;
&lt;br /&gt;
=== Controlling Lighttpd ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Start lighttpd&#039;&#039;&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|rc-service lighttpd start}}&lt;br /&gt;
&lt;br /&gt;
You will get feedback about the status.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 * Caching service dependencies                                 [ ok ]&lt;br /&gt;
 * Starting lighttpd...                                         [ ok ]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Stop lighttpd&#039;&#039;&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|rc-service lighttpd stop}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Restart lighttpd&#039;&#039;&#039;&#039;&#039;: After changing the configuration file, lighttpd needs to be restarted.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|rc-service lighttpd restart}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Proper Runlevel&#039;&#039;&#039;&#039;&#039;: By default no services are added to start process, sysadmin must know what we want and what will services do, also other main reason are due in dockers there&#039;s no runlevels per se and Alpine linux are mostly used in dockers containers. You must added the service only to the default runlevel, not to boot, because need networking activated&lt;br /&gt;
&lt;br /&gt;
{{Cmd|rc-update add lighttpd default}}&lt;br /&gt;
&lt;br /&gt;
== Lighttpd Configuration ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;If you just want to serve simple HTML pages, lighttpd can be used out-of-box. No further configuration needed.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
[https://wiki.lighttpd.net/Docs_ConfigurationOptions lighttpd configuration options]&lt;br /&gt;
&lt;br /&gt;
=== Status page ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Taking care of the status web server:&#039;&#039;&#039; those special pages are just minimal info of the running web server, are need to view from outside in a case of emergency, do not take the wrong approach of hide behind a filtered ip or filtered network, you must have access in all time in all the web to see problems.&lt;br /&gt;
&lt;br /&gt;
[https://wiki.lighttpd.net/mod_status mod_status]&lt;br /&gt;
&lt;br /&gt;
# Enable the mod_status at the config files&lt;br /&gt;
# change path in the config file (optional), we are using security by obfuscation&lt;br /&gt;
# restart the service to see changes at the browser&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;&lt;br /&gt;
sed -i -r &#039;s#\#.*mod_status.*,.*#    &amp;quot;mod_status&amp;quot;,#g&#039; /etc/lighttpd/lighttpd.conf&lt;br /&gt;
&lt;br /&gt;
sed -i -r &#039;s#.*status.status-url.*=.*#status.status-url  = &amp;quot;/stats/server-status&amp;quot;#g&#039; /etc/lighttpd/lighttpd.conf&lt;br /&gt;
&lt;br /&gt;
sed -i -r &#039;s#.*status.config-url.*=.*#status.config-url  = &amp;quot;/stats/server-config&amp;quot;#g&#039; /etc/lighttpd/lighttpd.conf&lt;br /&gt;
&lt;br /&gt;
rc-service lighttpd restart&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== CGI bin directory support ===&lt;br /&gt;
&lt;br /&gt;
By default packages assign a directory under localhost main domain, other linux uses a global cgi directory and aliasing.. the most professional way, but think about it, this per domain configuration allows isolation:&lt;br /&gt;
&lt;br /&gt;
[https://wiki.lighttpd.net/mod_cgi mod_cgi]&lt;br /&gt;
&lt;br /&gt;
# enable the mod_alias at the config file, due need of a specific path for cgi files into security&lt;br /&gt;
# create the directory&lt;br /&gt;
# enable the config cgi file&lt;br /&gt;
# restart the service to see changes at the browser&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;&lt;br /&gt;
mkdir -p /var/www/localhost/cgi-bin&lt;br /&gt;
&lt;br /&gt;
sed -i -r &#039;s#\#.*mod_alias.*,.*#    &amp;quot;mod_alias&amp;quot;,#g&#039; /etc/lighttpd/lighttpd.conf&lt;br /&gt;
&lt;br /&gt;
sed -i -r &#039;s#.*include &amp;quot;mod_cgi.conf&amp;quot;.*#   include &amp;quot;mod_cgi.conf&amp;quot;#g&#039; /etc/lighttpd/lighttpd.conf&lt;br /&gt;
&lt;br /&gt;
rc-service lighttpd restart&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After that, all the files under the &amp;lt;code&amp;gt;/var/www/localhost/cgi-bin&amp;lt;/code&amp;gt; directory will be accessed under &amp;lt;nowiki&amp;gt;http://localhost/cgi-bin/&amp;lt;/nowiki&amp;gt; path&lt;br /&gt;
&lt;br /&gt;
.cgi and .pl scripts are run using /usr/bin/perl.  Review and modify mod_cgi.conf others are needed.  Then restart lighttpd to pick up the changes.&lt;br /&gt;
&lt;br /&gt;
=== Make special errors (404 or 500) pages for clients and visitors ===&lt;br /&gt;
&lt;br /&gt;
These pages will be shown to visitors when a page or path is not present on the server, or when an internal error happens. &lt;br /&gt;
These replace the default, minimal error pages and can be a nice message or &amp;quot;away from here&amp;quot; message:&lt;br /&gt;
&lt;br /&gt;
[https://wiki.lighttpd.net/Server_errorfile-prefixDetails server.errorfile-prefix]&lt;br /&gt;
&lt;br /&gt;
# create the directory for put the html files to show when those errors occur&lt;br /&gt;
# create the simple files for each message in the directory&lt;br /&gt;
# set the proper in the configuration file&lt;br /&gt;
# restart the service to see the changes at the browser (just request a non existing page and you will see it)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;&lt;br /&gt;
mkdir -p /var/www/localhost/errors&lt;br /&gt;
&lt;br /&gt;
cat &amp;gt; /var/www/localhost/errors/status-404.html &amp;lt;&amp;lt; EOF&lt;br /&gt;
&amp;lt;h1&amp;gt;The page that you requested are not yet here anymore, sorry was moved or updated, search or visit another one&amp;lt;/h1&amp;gt;&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
cat &amp;gt; /var/www/localhost/errors/status-500.html &amp;lt;&amp;lt; EOF&lt;br /&gt;
&amp;lt;h1&amp;gt;Please wait a moment, there&#039;s something happens and we are give support maintenance right now to resolve&amp;lt;/h1&amp;gt;&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
cp /var/www/localhost/errors/status-404.html /var/www/localhost/errors/status-403.html&lt;br /&gt;
&lt;br /&gt;
cp /var/www/localhost/errors/status-500.html /var/www/localhost/errors/status-501.html&lt;br /&gt;
&lt;br /&gt;
cp /var/www/localhost/errors/status-500.html /var/www/localhost/errors/status-503.html&lt;br /&gt;
&lt;br /&gt;
sed -i -r &#039;s#.*server.errorfile-prefix.*#server.errorfile-prefix    = var.basedir + &amp;quot;/errors/status-&amp;quot;#g&#039; /etc/lighttpd/lighttpd.conf&lt;br /&gt;
&lt;br /&gt;
rc-service lighttpd restart&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Userdir public_html support ===&lt;br /&gt;
&lt;br /&gt;
[https://wiki.lighttpd.net/mod_userdir mod_userdir]&lt;br /&gt;
&lt;br /&gt;
== Lighttpd SSL support ==&lt;br /&gt;
&lt;br /&gt;
[https://wiki.lighttpd.net/Docs_SSL lighttpd TLS doc]&lt;br /&gt;
&lt;br /&gt;
Create TLS configuration for lighttpd.  Best way to do that is by external include files. Debian counterpart has a good mechanism that enables configuration files.  We will add SSL support in a similar way.&lt;br /&gt;
&lt;br /&gt;
=== SSL : making self signed certificate ===&lt;br /&gt;
&lt;br /&gt;
We need to created a self-signed certificate if we do not already have one:&lt;br /&gt;
&lt;br /&gt;
# install openssl&lt;br /&gt;
# create the self signed certificate&lt;br /&gt;
# set proper permissions&lt;br /&gt;
# create a SSL module configuration file for lighttpd&lt;br /&gt;
# activate the openssl module missing from config file&lt;br /&gt;
# activate the mod_redirect in case of global http to https redirections&lt;br /&gt;
# restart the service to see changes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;&lt;br /&gt;
apk add openssl&lt;br /&gt;
&lt;br /&gt;
mkdir -p /etc/ssl/certs/&lt;br /&gt;
&lt;br /&gt;
openssl req -x509 -days 1460 -nodes -newkey rsa:4096 \&lt;br /&gt;
   -subj &amp;quot;/C=VE/ST=Bolivar/L=Upata/O=VenenuX/OU=Systemas:hozYmartillo/CN=$(hostname -d)&amp;quot; \&lt;br /&gt;
   -keyout /etc/ssl/certs/$(hostname -d).pem -out /etc/ssl/certs/$(hostname -d).pem&lt;br /&gt;
&lt;br /&gt;
chmod 640 /etc/ssl/certs/$(hostname -d).pem&lt;br /&gt;
&lt;br /&gt;
cat &amp;gt; /etc/lighttpd/mod_ssl.conf &amp;lt;&amp;lt; EOF&lt;br /&gt;
server.modules += (&amp;quot;mod_openssl&amp;quot;)&lt;br /&gt;
\$SERVER[&amp;quot;socket&amp;quot;] == &amp;quot;0.0.0.0:443&amp;quot; {&lt;br /&gt;
	ssl.engine  = &amp;quot;enable&amp;quot;&lt;br /&gt;
	ssl.pemfile = &amp;quot;/etc/ssl/certs/$(hostname -d).pem&amp;quot;&lt;br /&gt;
	ssl.cipher-list = &amp;quot;ECDHE-RSA-AES256-SHA384:AES256-SHA256:RC4:HIGH:!MD5:!aNULL:!EDH:!AESGCM&amp;quot;&lt;br /&gt;
	ssl.honor-cipher-order = &amp;quot;enable&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
\$HTTP[&amp;quot;scheme&amp;quot;] == &amp;quot;http&amp;quot; {&lt;br /&gt;
    url.redirect = (&amp;quot;&amp;quot; =&amp;gt; &amp;quot;https://\${url.authority}\${url.path}\${qsa}&amp;quot;)&lt;br /&gt;
    url.redirect-code = 308&lt;br /&gt;
}&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
sed -i -r &#039;s#\#.*mod_redirect.*,.*#    &amp;quot;mod_redirect&amp;quot;,#g&#039; /etc/lighttpd/lighttpd.conf&lt;br /&gt;
&lt;br /&gt;
checkssl=&amp;quot;&amp;quot;;checkssl=$(grep &#039;include &amp;quot;mod_ssl.conf&#039; /etc/lighttpd/lighttpd.conf);[[ &amp;quot;$checkssl&amp;quot; != &amp;quot;&amp;quot; ]] &amp;amp;&amp;amp; echo listo || sed -i -r &#039;s#.*include &amp;quot;mime-types.conf&amp;quot;.*#include &amp;quot;mime-types.conf&amp;quot;\ninclude &amp;quot;mod_ssl.conf&amp;quot;#g&#039; /etc/lighttpd/lighttpd.conf&lt;br /&gt;
&lt;br /&gt;
rc-service lighttpd restart&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For deploy usage of Lets Encrypt without chain-tools (just add water) read [https://wiki.lighttpd.net/HowToSimpleSSL HowToSimpleSSL].&lt;br /&gt;
&lt;br /&gt;
== Lighttpd advanced ==&lt;br /&gt;
&lt;br /&gt;
Lighttpd has pretty good default settings, but a few might be tweaked if we need to respond to higher server loads.&lt;br /&gt;
&lt;br /&gt;
[https://wiki.lighttpd.net/Docs_ResourceTuning lighttpd resource tuning]&lt;br /&gt;
&lt;br /&gt;
=== Lighttpd tunning for aggressive load ===&lt;br /&gt;
&lt;br /&gt;
[https://wiki.lighttpd.net/Docs_Performance lighttpd performance tuning]&lt;br /&gt;
&lt;br /&gt;
=== More connections, More File Descriptors ===&lt;br /&gt;
&lt;br /&gt;
This must be used with caution.  Everything is a file to a UNIX operating system. Well, every time a visitor accesses a page, lighttpd uses three file descriptors: An IP socket to the client, a FastCGI process socket, and a filehandle for the document accessed. Lighttpd stops accepting new connections when 90% of the available sockets are in use, restarting again when usage has fallen to 80%. With the default setting of 1024 file descriptors, lighttpd can handle a maximum of 307 connections. If this number are exceded file descriptor must be increrased then. This are a delicate tune due must be check your default with &amp;lt;code&amp;gt;cat /proc/sys/fs/file-max&amp;lt;/code&amp;gt; and make sure it’s over 10,000:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;&lt;br /&gt;
checkset=&amp;quot;&amp;quot;;checkset=$(grep &#039;max-fds&#039; /etc/lighttpd/lighttpd.conf);[[ &amp;quot;$checkset&amp;quot; != &amp;quot;&amp;quot; ]] &amp;amp;&amp;amp; echo listo || sed -i -r &#039;s#server settings.*#server settings\nserver.max-fds = 2048\n#g&#039; /etc/lighttpd/lighttpd.conf&lt;br /&gt;
&lt;br /&gt;
rc-service lighttpd restart&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== HTTP Keep-Alive for aggressive load ===&lt;br /&gt;
&lt;br /&gt;
One reason that file descriptors get used up so quickly is HTTP keep-alive. To improve performance, modern web servers keep client connections alive to handle multiple requests instead of building up and tearing down connections for each item in a page. Keep-alive is tremendously beneficial to performance, but tends to keep unnecessary connections alive, too. lighttpd allows 1000 keep-alive requests per connection, allows idle sessions to remain alive for 5 seconds, and gives reads and writes 1 minute and 6 minutes to complete, respectively.&lt;br /&gt;
&lt;br /&gt;
# Maximum number of request within a keep-alive session before the server terminates the connection, default = 1000 (&amp;lt;code&amp;gt;server.max-keep-alive-requests&amp;lt;/code&amp;gt;)&lt;br /&gt;
# Maximum number of seconds until an idling keep-alive connection is dropped, default = 5 (&amp;lt;code&amp;gt;server.max-keep-alive-idle&amp;lt;/code&amp;gt;)&lt;br /&gt;
# Maximum number of seconds until a waiting, non keep-alive read times out and closes the connection, default = 60 (&amp;lt;code&amp;gt;server.max-read-idle&amp;lt;/code&amp;gt;)&lt;br /&gt;
# Maximum number of seconds until a waiting write call times out and closes the connection, default = 360 (&amp;lt;code&amp;gt;server.max-write-idle&amp;lt;/code&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
Although lighttpd has pretty aggressive defaults (especially compared to Apache), a period of heavy traffic and a few slow clients could see many unused connections sticking around. The server.max-keep-alive-idle setting default of 5 seconds can be reduced to as low as 2, if you assume your clients are reasonably quick about requesting data, but a value of 3 or 4 is probably realistic. You may want to increase the server.max-keep-alive-requests value from the default of 1000, but you probably don’t need to. The server.max-read-idle and server.max-write-idle settings are tempting targets, but these situations are usually fairly rare so let’s not monkey with them.&lt;br /&gt;
&lt;br /&gt;
=== Lighttpd_Advanced_security ===&lt;br /&gt;
&lt;br /&gt;
See at [[Lighttpd_Advanced_security]] wiki page.&lt;br /&gt;
&lt;br /&gt;
=== Lighttpd and PHP with fpm ===&lt;br /&gt;
&lt;br /&gt;
In production web, LAMP means &#039;&#039;&#039;L&#039;&#039;&#039;inux + &#039;&#039;&#039;A&#039;&#039;&#039;pache + &#039;&#039;&#039;M&#039;&#039;&#039;ysql + &#039;&#039;&#039;P&#039;&#039;&#039;hp installed and integrated, but today the &amp;quot;A&amp;quot; of apache are more used as Nginx or Lighttpd, and the &amp;quot;M&amp;quot; of MySQL are more used as Mariadb, the LAMP focused documents are:&lt;br /&gt;
&lt;br /&gt;
* LAMP deploy of the Web Server with PHP, user html_dir and MariaDB: [[Production LAMP system: Lighttpd + PHP + MySQL]]&lt;br /&gt;
* LAMP deploy of the Web Server with PHP 5.6 and MariaDB: [[Production LAMP system: Lighttpd + PHP5 + MySQL]]&lt;br /&gt;
&lt;br /&gt;
= See Also =&lt;br /&gt;
&lt;br /&gt;
* [[Production LAMP system: Lighttpd + PHP + MySQL]]&lt;br /&gt;
* [[Alpine newbie developer]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Newbie]]&lt;br /&gt;
[[Category:Server]]&lt;br /&gt;
[[Category:Web_Server]]&lt;br /&gt;
[[Category:Monitoring]]&lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
[[Category:Security]]&lt;br /&gt;
[[Category:Production]]&lt;/div&gt;</summary>
		<author><name>Gstrauss</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Production_Web_server:_Lighttpd&amp;diff=22799</id>
		<title>Production Web server: Lighttpd</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Production_Web_server:_Lighttpd&amp;diff=22799"/>
		<updated>2022-12-22T17:54:41Z</updated>

		<summary type="html">&lt;p&gt;Gstrauss: /* SSL : making self signed certificate */  remove excess backslashes&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
[http://www.lighttpd.net/ lighttpd] is a simple, standards-compliant, secure, and flexible web server. &lt;br /&gt;
&lt;br /&gt;
== Lighttpd Installation ==&lt;br /&gt;
&lt;br /&gt;
This production environment will handle only the necessary packages... so no doc or manpages allowed.&lt;br /&gt;
&lt;br /&gt;
# make the htdocs public web root directories &lt;br /&gt;
# added the service to the default runlevel, not to boot, because need networking activated&lt;br /&gt;
# start the web server service&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;&lt;br /&gt;
mkdir -p /var/www/localhost/htdocs /var/log/lighttpd /var/lib/lighttpd&lt;br /&gt;
&lt;br /&gt;
chown -R lighttpd:lighttpd /var/www/localhost/ /var/log/lighttpd /var/lib/lighttpd &lt;br /&gt;
&lt;br /&gt;
rc-update add lighttpd default&lt;br /&gt;
&lt;br /&gt;
rc-service lighttpd restart&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;it works&amp;quot; &amp;gt; /var/www/localhost/htdocs/index.html&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;For testing, open a browser and go to &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;http://&amp;lt;webserveripaddres&amp;gt;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; and you will see &amp;quot;it works&amp;quot;&#039;&#039;&#039;. The &amp;quot;webserveripaddres&amp;quot; is the ip address of your setup/server machine.&lt;br /&gt;
&lt;br /&gt;
=== Controlling Lighttpd ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Start lighttpd&#039;&#039;&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|rc-service lighttpd start}}&lt;br /&gt;
&lt;br /&gt;
You will get feedback about the status.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 * Caching service dependencies                                 [ ok ]&lt;br /&gt;
 * Starting lighttpd...                                         [ ok ]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Stop lighttpd&#039;&#039;&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|rc-service lighttpd stop}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Restart lighttpd&#039;&#039;&#039;&#039;&#039;: After changing the configuration file, lighttpd needs to be restarted.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|rc-service lighttpd restart}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Proper Runlevel&#039;&#039;&#039;&#039;&#039;: By default no services are added to start process, sysadmin must know what we want and what will services do, also other main reason are due in dockers there&#039;s no runlevels per se and Alpine linux are mostly used in dockers containers. You must added the service only to the default runlevel, not to boot, because need networking activated&lt;br /&gt;
&lt;br /&gt;
{{Cmd|rc-update add lighttpd default}}&lt;br /&gt;
&lt;br /&gt;
== Lighttpd Configuration ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;If you just want to serve simple HTML pages, lighttpd can be used out-of-box. No further configuration needed.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
[https://wiki.lighttpd.net/Docs_ConfigurationOptions lighttpd configuration options]&lt;br /&gt;
&lt;br /&gt;
=== Status page ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Taking care of the status web server:&#039;&#039;&#039; those special pages are just minimal info of the running web server, are need to view from outside in a case of emergency, do not take the wrong approach of hide behind a filtered ip or filtered network, you must have access in all time in all the web to see problems.&lt;br /&gt;
&lt;br /&gt;
[https://wiki.lighttpd.net/mod_status mod_status]&lt;br /&gt;
&lt;br /&gt;
# Enable the mod_status at the config files&lt;br /&gt;
# change path in the config file (optional), we are using security by obfuscation&lt;br /&gt;
# restart the service to see changes at the browser&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;&lt;br /&gt;
sed -i -r &#039;s#\#.*mod_status.*,.*#    &amp;quot;mod_status&amp;quot;,#g&#039; /etc/lighttpd/lighttpd.conf&lt;br /&gt;
&lt;br /&gt;
sed -i -r &#039;s#.*status.status-url.*=.*#status.status-url  = &amp;quot;/stats/server-status&amp;quot;#g&#039; /etc/lighttpd/lighttpd.conf&lt;br /&gt;
&lt;br /&gt;
sed -i -r &#039;s#.*status.config-url.*=.*#status.config-url  = &amp;quot;/stats/server-config&amp;quot;#g&#039; /etc/lighttpd/lighttpd.conf&lt;br /&gt;
&lt;br /&gt;
rc-service lighttpd restart&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== CGI bin directory support ===&lt;br /&gt;
&lt;br /&gt;
By default packages assign a directory under localhost main domain, other linux uses a global cgi directory and aliasing.. the most professional way, but think about it, this per domain configuration allows isolation:&lt;br /&gt;
&lt;br /&gt;
[https://wiki.lighttpd.net/mod_cgi mod_cgi]&lt;br /&gt;
&lt;br /&gt;
# enable the mod_alias at the config file, due need of a specific path for cgi files into security&lt;br /&gt;
# create the directory&lt;br /&gt;
# enable the config cgi file&lt;br /&gt;
# restart the service to see changes at the browser&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;&lt;br /&gt;
mkdir -p /var/www/localhost/cgi-bin&lt;br /&gt;
&lt;br /&gt;
sed -i -r &#039;s#\#.*mod_alias.*,.*#    &amp;quot;mod_alias&amp;quot;,#g&#039; /etc/lighttpd/lighttpd.conf&lt;br /&gt;
&lt;br /&gt;
sed -i -r &#039;s#.*include &amp;quot;mod_cgi.conf&amp;quot;.*#   include &amp;quot;mod_cgi.conf&amp;quot;#g&#039; /etc/lighttpd/lighttpd.conf&lt;br /&gt;
&lt;br /&gt;
rc-service lighttpd restart&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After that, all the files under the &amp;lt;code&amp;gt;/var/www/localhost/cgi-bin&amp;lt;/code&amp;gt; directory will be accessed under &amp;lt;nowiki&amp;gt;http://localhost/cgi-bin/&amp;lt;/nowiki&amp;gt; path&lt;br /&gt;
&lt;br /&gt;
.cgi and .pl scripts are run using /usr/bin/perl.  Review and modify mod_cgi.conf others are needed.  Then restart lighttpd to pick up the changes.&lt;br /&gt;
&lt;br /&gt;
=== Make special errors (404 or 500) pages for clients and visitors ===&lt;br /&gt;
&lt;br /&gt;
These pages will be shown to visitors when a page or path is not present on the server, or when an internal error happens. &lt;br /&gt;
These replace the default, minimal error pages and can be a nice message or &amp;quot;away from here&amp;quot; message:&lt;br /&gt;
&lt;br /&gt;
[https://wiki.lighttpd.net/Server_errorfile-prefixDetails server.errorfile-prefix]&lt;br /&gt;
&lt;br /&gt;
# create the directory for put the html files to show when those errors occur&lt;br /&gt;
# create the simple files for each message in the directory&lt;br /&gt;
# set the proper in the configuration file&lt;br /&gt;
# restart the service to see the changes at the browser (just request a non existing page and you will see it)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;&lt;br /&gt;
mkdir -p /var/www/localhost/errors&lt;br /&gt;
&lt;br /&gt;
cat &amp;gt; /var/www/localhost/errors/status-404.html &amp;lt;&amp;lt; EOF&lt;br /&gt;
&amp;lt;h1&amp;gt;The page that you requested are not yet here anymore, sorry was moved or updated, search or visit another one&amp;lt;/h1&amp;gt;&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
cat &amp;gt; /var/www/localhost/errors/status-500.html &amp;lt;&amp;lt; EOF&lt;br /&gt;
&amp;lt;h1&amp;gt;Please wait a moment, there&#039;s something happens and we are give support maintenance right now to resolve&amp;lt;/h1&amp;gt;&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
cp /var/www/localhost/errors/status-404.html /var/www/localhost/errors/status-403.html&lt;br /&gt;
&lt;br /&gt;
cp /var/www/localhost/errors/status-500.html /var/www/localhost/errors/status-501.html&lt;br /&gt;
&lt;br /&gt;
cp /var/www/localhost/errors/status-500.html /var/www/localhost/errors/status-503.html&lt;br /&gt;
&lt;br /&gt;
sed -i -r &#039;s#.*server.errorfile-prefix.*#server.errorfile-prefix    = var.basedir + &amp;quot;/errors/status-&amp;quot;#g&#039; /etc/lighttpd/lighttpd.conf&lt;br /&gt;
&lt;br /&gt;
rc-service lighttpd restart&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Userdir public_html support ===&lt;br /&gt;
&lt;br /&gt;
[https://wiki.lighttpd.net/mod_userdir mod_userdir]&lt;br /&gt;
&lt;br /&gt;
== Lighttpd SSL support ==&lt;br /&gt;
&lt;br /&gt;
[https://wiki.lighttpd.net/Docs_SSL lighttpd TLS doc]&lt;br /&gt;
&lt;br /&gt;
Create TLS configuration for lighttpd.  Best way to do that is by external include files. Debian counterpart has a good mechanism that enables configuration files.  We will add SSL support in a similar way.&lt;br /&gt;
&lt;br /&gt;
=== SSL : making self signed certificate ===&lt;br /&gt;
&lt;br /&gt;
We need to created a self-signed certificate if we do not already have one:&lt;br /&gt;
&lt;br /&gt;
# install openssl&lt;br /&gt;
# create the self signed certificate&lt;br /&gt;
# set proper permissions&lt;br /&gt;
# create a SSL module configuration file for lighttpd&lt;br /&gt;
# activate the openssl module missing from config file&lt;br /&gt;
# activate the mod_redirect in case of global http to https redirections&lt;br /&gt;
# restart the service to see changes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;&lt;br /&gt;
apk add openssl&lt;br /&gt;
&lt;br /&gt;
mkdir -p /etc/ssl/certs/&lt;br /&gt;
&lt;br /&gt;
openssl req -x509 -days 1460 -nodes -newkey rsa:4096 \&lt;br /&gt;
   -subj &amp;quot;/C=VE/ST=Bolivar/L=Upata/O=VenenuX/OU=Systemas:hozYmartillo/CN=$(hostname -d)&amp;quot; \&lt;br /&gt;
   -keyout /etc/ssl/certs/$(hostname -d).pem -out /etc/ssl/certs/$(hostname -d).pem&lt;br /&gt;
&lt;br /&gt;
chmod 640 /etc/ssl/certs/$(hostname -d).pem&lt;br /&gt;
&lt;br /&gt;
cat &amp;gt; /etc/lighttpd/mod_ssl.conf &amp;lt;&amp;lt; EOF&lt;br /&gt;
server.modules += (&amp;quot;mod_openssl&amp;quot;)&lt;br /&gt;
$SERVER[&amp;quot;socket&amp;quot;] == &amp;quot;0.0.0.0:443&amp;quot; {&lt;br /&gt;
	ssl.engine  = &amp;quot;enable&amp;quot;&lt;br /&gt;
	ssl.pemfile = &amp;quot;/etc/ssl/certs/$(hostname -d).pem&amp;quot;&lt;br /&gt;
	ssl.cipher-list = &amp;quot;ECDHE-RSA-AES256-SHA384:AES256-SHA256:RC4:HIGH:!MD5:!aNULL:!EDH:!AESGCM&amp;quot;&lt;br /&gt;
	ssl.honor-cipher-order = &amp;quot;enable&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
$HTTP[&amp;quot;scheme&amp;quot;] == &amp;quot;http&amp;quot; {&lt;br /&gt;
    url.redirect = (&amp;quot;&amp;quot; =&amp;gt; &amp;quot;https://${url.authority}${url.path}${qsa}&amp;quot;)&lt;br /&gt;
    url.redirect-code = 308&lt;br /&gt;
}&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
sed -i -r &#039;s#\#.*mod_redirect.*,.*#    &amp;quot;mod_redirect&amp;quot;,#g&#039; /etc/lighttpd/lighttpd.conf&lt;br /&gt;
&lt;br /&gt;
checkssl=&amp;quot;&amp;quot;;checkssl=$(grep &#039;include &amp;quot;mod_ssl.conf&#039; /etc/lighttpd/lighttpd.conf);[[ &amp;quot;$checkssl&amp;quot; != &amp;quot;&amp;quot; ]] &amp;amp;&amp;amp; echo listo || sed -i -r &#039;s#.*include &amp;quot;mime-types.conf&amp;quot;.*#include &amp;quot;mime-types.conf&amp;quot;\ninclude &amp;quot;mod_ssl.conf&amp;quot;#g&#039; /etc/lighttpd/lighttpd.conf&lt;br /&gt;
&lt;br /&gt;
rc-service lighttpd restart&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For deploy usage of Lets Encrypt without chain-tools (just add water) read [https://wiki.lighttpd.net/HowToSimpleSSL HowToSimpleSSL].&lt;br /&gt;
&lt;br /&gt;
== Lighttpd advanced ==&lt;br /&gt;
&lt;br /&gt;
Lighttpd has pretty good default settings, but a few might be tweaked if we need to respond to higher server loads.&lt;br /&gt;
&lt;br /&gt;
[https://wiki.lighttpd.net/Docs_ResourceTuning lighttpd resource tuning]&lt;br /&gt;
&lt;br /&gt;
=== Lighttpd tunning for aggressive load ===&lt;br /&gt;
&lt;br /&gt;
[https://wiki.lighttpd.net/Docs_Performance lighttpd performance tuning]&lt;br /&gt;
&lt;br /&gt;
=== More connections, More File Descriptors ===&lt;br /&gt;
&lt;br /&gt;
This must be used with caution.  Everything is a file to a UNIX operating system. Well, every time a visitor accesses a page, lighttpd uses three file descriptors: An IP socket to the client, a FastCGI process socket, and a filehandle for the document accessed. Lighttpd stops accepting new connections when 90% of the available sockets are in use, restarting again when usage has fallen to 80%. With the default setting of 1024 file descriptors, lighttpd can handle a maximum of 307 connections. If this number are exceded file descriptor must be increrased then. This are a delicate tune due must be check your default with &amp;lt;code&amp;gt;cat /proc/sys/fs/file-max&amp;lt;/code&amp;gt; and make sure it’s over 10,000:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;&lt;br /&gt;
checkset=&amp;quot;&amp;quot;;checkset=$(grep &#039;max-fds&#039; /etc/lighttpd/lighttpd.conf);[[ &amp;quot;$checkset&amp;quot; != &amp;quot;&amp;quot; ]] &amp;amp;&amp;amp; echo listo || sed -i -r &#039;s#server settings.*#server settings\nserver.max-fds = 2048\n#g&#039; /etc/lighttpd/lighttpd.conf&lt;br /&gt;
&lt;br /&gt;
rc-service lighttpd restart&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== HTTP Keep-Alive for aggressive load ===&lt;br /&gt;
&lt;br /&gt;
One reason that file descriptors get used up so quickly is HTTP keep-alive. To improve performance, modern web servers keep client connections alive to handle multiple requests instead of building up and tearing down connections for each item in a page. Keep-alive is tremendously beneficial to performance, but tends to keep unnecessary connections alive, too. lighttpd allows 1000 keep-alive requests per connection, allows idle sessions to remain alive for 5 seconds, and gives reads and writes 1 minute and 6 minutes to complete, respectively.&lt;br /&gt;
&lt;br /&gt;
# Maximum number of request within a keep-alive session before the server terminates the connection, default = 1000 (&amp;lt;code&amp;gt;server.max-keep-alive-requests&amp;lt;/code&amp;gt;)&lt;br /&gt;
# Maximum number of seconds until an idling keep-alive connection is dropped, default = 5 (&amp;lt;code&amp;gt;server.max-keep-alive-idle&amp;lt;/code&amp;gt;)&lt;br /&gt;
# Maximum number of seconds until a waiting, non keep-alive read times out and closes the connection, default = 60 (&amp;lt;code&amp;gt;server.max-read-idle&amp;lt;/code&amp;gt;)&lt;br /&gt;
# Maximum number of seconds until a waiting write call times out and closes the connection, default = 360 (&amp;lt;code&amp;gt;server.max-write-idle&amp;lt;/code&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
Although lighttpd has pretty aggressive defaults (especially compared to Apache), a period of heavy traffic and a few slow clients could see many unused connections sticking around. The server.max-keep-alive-idle setting default of 5 seconds can be reduced to as low as 2, if you assume your clients are reasonably quick about requesting data, but a value of 3 or 4 is probably realistic. You may want to increase the server.max-keep-alive-requests value from the default of 1000, but you probably don’t need to. The server.max-read-idle and server.max-write-idle settings are tempting targets, but these situations are usually fairly rare so let’s not monkey with them.&lt;br /&gt;
&lt;br /&gt;
=== Lighttpd_Advanced_security ===&lt;br /&gt;
&lt;br /&gt;
See at [[Lighttpd_Advanced_security]] wiki page.&lt;br /&gt;
&lt;br /&gt;
=== Lighttpd and PHP with fpm ===&lt;br /&gt;
&lt;br /&gt;
In production web, LAMP means &#039;&#039;&#039;L&#039;&#039;&#039;inux + &#039;&#039;&#039;A&#039;&#039;&#039;pache + &#039;&#039;&#039;M&#039;&#039;&#039;ysql + &#039;&#039;&#039;P&#039;&#039;&#039;hp installed and integrated, but today the &amp;quot;A&amp;quot; of apache are more used as Nginx or Lighttpd, and the &amp;quot;M&amp;quot; of MySQL are more used as Mariadb, the LAMP focused documents are:&lt;br /&gt;
&lt;br /&gt;
* LAMP deploy of the Web Server with PHP, user html_dir and MariaDB: [[Production LAMP system: Lighttpd + PHP + MySQL]]&lt;br /&gt;
* LAMP deploy of the Web Server with PHP 5.6 and MariaDB: [[Production LAMP system: Lighttpd + PHP5 + MySQL]]&lt;br /&gt;
&lt;br /&gt;
= See Also =&lt;br /&gt;
&lt;br /&gt;
* [[Production LAMP system: Lighttpd + PHP + MySQL]]&lt;br /&gt;
* [[Alpine newbie developer]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Newbie]]&lt;br /&gt;
[[Category:Server]]&lt;br /&gt;
[[Category:Web_Server]]&lt;br /&gt;
[[Category:Monitoring]]&lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
[[Category:Security]]&lt;br /&gt;
[[Category:Production]]&lt;/div&gt;</summary>
		<author><name>Gstrauss</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Production_Web_server:_Lighttpd&amp;diff=22798</id>
		<title>Production Web server: Lighttpd</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Production_Web_server:_Lighttpd&amp;diff=22798"/>
		<updated>2022-12-22T17:53:25Z</updated>

		<summary type="html">&lt;p&gt;Gstrauss: modernize&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
[http://www.lighttpd.net/ lighttpd] is a simple, standards-compliant, secure, and flexible web server. &lt;br /&gt;
&lt;br /&gt;
== Lighttpd Installation ==&lt;br /&gt;
&lt;br /&gt;
This production environment will handle only the necessary packages... so no doc or manpages allowed.&lt;br /&gt;
&lt;br /&gt;
# make the htdocs public web root directories &lt;br /&gt;
# added the service to the default runlevel, not to boot, because need networking activated&lt;br /&gt;
# start the web server service&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;&lt;br /&gt;
mkdir -p /var/www/localhost/htdocs /var/log/lighttpd /var/lib/lighttpd&lt;br /&gt;
&lt;br /&gt;
chown -R lighttpd:lighttpd /var/www/localhost/ /var/log/lighttpd /var/lib/lighttpd &lt;br /&gt;
&lt;br /&gt;
rc-update add lighttpd default&lt;br /&gt;
&lt;br /&gt;
rc-service lighttpd restart&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;it works&amp;quot; &amp;gt; /var/www/localhost/htdocs/index.html&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;For testing, open a browser and go to &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;http://&amp;lt;webserveripaddres&amp;gt;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; and you will see &amp;quot;it works&amp;quot;&#039;&#039;&#039;. The &amp;quot;webserveripaddres&amp;quot; is the ip address of your setup/server machine.&lt;br /&gt;
&lt;br /&gt;
=== Controlling Lighttpd ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Start lighttpd&#039;&#039;&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|rc-service lighttpd start}}&lt;br /&gt;
&lt;br /&gt;
You will get feedback about the status.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 * Caching service dependencies                                 [ ok ]&lt;br /&gt;
 * Starting lighttpd...                                         [ ok ]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Stop lighttpd&#039;&#039;&#039;&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|rc-service lighttpd stop}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Restart lighttpd&#039;&#039;&#039;&#039;&#039;: After changing the configuration file, lighttpd needs to be restarted.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|rc-service lighttpd restart}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Proper Runlevel&#039;&#039;&#039;&#039;&#039;: By default no services are added to start process, sysadmin must know what we want and what will services do, also other main reason are due in dockers there&#039;s no runlevels per se and Alpine linux are mostly used in dockers containers. You must added the service only to the default runlevel, not to boot, because need networking activated&lt;br /&gt;
&lt;br /&gt;
{{Cmd|rc-update add lighttpd default}}&lt;br /&gt;
&lt;br /&gt;
== Lighttpd Configuration ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;If you just want to serve simple HTML pages, lighttpd can be used out-of-box. No further configuration needed.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
[https://wiki.lighttpd.net/Docs_ConfigurationOptions lighttpd configuration options]&lt;br /&gt;
&lt;br /&gt;
=== Status page ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Taking care of the status web server:&#039;&#039;&#039; those special pages are just minimal info of the running web server, are need to view from outside in a case of emergency, do not take the wrong approach of hide behind a filtered ip or filtered network, you must have access in all time in all the web to see problems.&lt;br /&gt;
&lt;br /&gt;
[https://wiki.lighttpd.net/mod_status mod_status]&lt;br /&gt;
&lt;br /&gt;
# Enable the mod_status at the config files&lt;br /&gt;
# change path in the config file (optional), we are using security by obfuscation&lt;br /&gt;
# restart the service to see changes at the browser&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;&lt;br /&gt;
sed -i -r &#039;s#\#.*mod_status.*,.*#    &amp;quot;mod_status&amp;quot;,#g&#039; /etc/lighttpd/lighttpd.conf&lt;br /&gt;
&lt;br /&gt;
sed -i -r &#039;s#.*status.status-url.*=.*#status.status-url  = &amp;quot;/stats/server-status&amp;quot;#g&#039; /etc/lighttpd/lighttpd.conf&lt;br /&gt;
&lt;br /&gt;
sed -i -r &#039;s#.*status.config-url.*=.*#status.config-url  = &amp;quot;/stats/server-config&amp;quot;#g&#039; /etc/lighttpd/lighttpd.conf&lt;br /&gt;
&lt;br /&gt;
rc-service lighttpd restart&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== CGI bin directory support ===&lt;br /&gt;
&lt;br /&gt;
By default packages assign a directory under localhost main domain, other linux uses a global cgi directory and aliasing.. the most professional way, but think about it, this per domain configuration allows isolation:&lt;br /&gt;
&lt;br /&gt;
[https://wiki.lighttpd.net/mod_cgi mod_cgi]&lt;br /&gt;
&lt;br /&gt;
# enable the mod_alias at the config file, due need of a specific path for cgi files into security&lt;br /&gt;
# create the directory&lt;br /&gt;
# enable the config cgi file&lt;br /&gt;
# restart the service to see changes at the browser&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;&lt;br /&gt;
mkdir -p /var/www/localhost/cgi-bin&lt;br /&gt;
&lt;br /&gt;
sed -i -r &#039;s#\#.*mod_alias.*,.*#    &amp;quot;mod_alias&amp;quot;,#g&#039; /etc/lighttpd/lighttpd.conf&lt;br /&gt;
&lt;br /&gt;
sed -i -r &#039;s#.*include &amp;quot;mod_cgi.conf&amp;quot;.*#   include &amp;quot;mod_cgi.conf&amp;quot;#g&#039; /etc/lighttpd/lighttpd.conf&lt;br /&gt;
&lt;br /&gt;
rc-service lighttpd restart&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After that, all the files under the &amp;lt;code&amp;gt;/var/www/localhost/cgi-bin&amp;lt;/code&amp;gt; directory will be accessed under &amp;lt;nowiki&amp;gt;http://localhost/cgi-bin/&amp;lt;/nowiki&amp;gt; path&lt;br /&gt;
&lt;br /&gt;
.cgi and .pl scripts are run using /usr/bin/perl.  Review and modify mod_cgi.conf others are needed.  Then restart lighttpd to pick up the changes.&lt;br /&gt;
&lt;br /&gt;
=== Make special errors (404 or 500) pages for clients and visitors ===&lt;br /&gt;
&lt;br /&gt;
These pages will be shown to visitors when a page or path is not present on the server, or when an internal error happens. &lt;br /&gt;
These replace the default, minimal error pages and can be a nice message or &amp;quot;away from here&amp;quot; message:&lt;br /&gt;
&lt;br /&gt;
[https://wiki.lighttpd.net/Server_errorfile-prefixDetails server.errorfile-prefix]&lt;br /&gt;
&lt;br /&gt;
# create the directory for put the html files to show when those errors occur&lt;br /&gt;
# create the simple files for each message in the directory&lt;br /&gt;
# set the proper in the configuration file&lt;br /&gt;
# restart the service to see the changes at the browser (just request a non existing page and you will see it)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;&lt;br /&gt;
mkdir -p /var/www/localhost/errors&lt;br /&gt;
&lt;br /&gt;
cat &amp;gt; /var/www/localhost/errors/status-404.html &amp;lt;&amp;lt; EOF&lt;br /&gt;
&amp;lt;h1&amp;gt;The page that you requested are not yet here anymore, sorry was moved or updated, search or visit another one&amp;lt;/h1&amp;gt;&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
cat &amp;gt; /var/www/localhost/errors/status-500.html &amp;lt;&amp;lt; EOF&lt;br /&gt;
&amp;lt;h1&amp;gt;Please wait a moment, there&#039;s something happens and we are give support maintenance right now to resolve&amp;lt;/h1&amp;gt;&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
cp /var/www/localhost/errors/status-404.html /var/www/localhost/errors/status-403.html&lt;br /&gt;
&lt;br /&gt;
cp /var/www/localhost/errors/status-500.html /var/www/localhost/errors/status-501.html&lt;br /&gt;
&lt;br /&gt;
cp /var/www/localhost/errors/status-500.html /var/www/localhost/errors/status-503.html&lt;br /&gt;
&lt;br /&gt;
sed -i -r &#039;s#.*server.errorfile-prefix.*#server.errorfile-prefix    = var.basedir + &amp;quot;/errors/status-&amp;quot;#g&#039; /etc/lighttpd/lighttpd.conf&lt;br /&gt;
&lt;br /&gt;
rc-service lighttpd restart&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Userdir public_html support ===&lt;br /&gt;
&lt;br /&gt;
[https://wiki.lighttpd.net/mod_userdir mod_userdir]&lt;br /&gt;
&lt;br /&gt;
== Lighttpd SSL support ==&lt;br /&gt;
&lt;br /&gt;
[https://wiki.lighttpd.net/Docs_SSL lighttpd TLS doc]&lt;br /&gt;
&lt;br /&gt;
Create TLS configuration for lighttpd.  Best way to do that is by external include files. Debian counterpart has a good mechanism that enables configuration files.  We will add SSL support in a similar way.&lt;br /&gt;
&lt;br /&gt;
=== SSL : making self signed certificate ===&lt;br /&gt;
&lt;br /&gt;
We need to created a self-signed certificate if we do not already have one:&lt;br /&gt;
&lt;br /&gt;
# install openssl&lt;br /&gt;
# create the self signed certificate&lt;br /&gt;
# set proper permissions&lt;br /&gt;
# create a SSL module configuration file for lighttpd&lt;br /&gt;
# activate the openssl module missing from config file&lt;br /&gt;
# activate the mod_redirect in case of global http to https redirections&lt;br /&gt;
# restart the service to see changes&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;&lt;br /&gt;
apk add openssl&lt;br /&gt;
&lt;br /&gt;
mkdir -p /etc/ssl/certs/&lt;br /&gt;
&lt;br /&gt;
openssl req -x509 -days 1460 -nodes -newkey rsa:4096 \&lt;br /&gt;
   -subj &amp;quot;/C=VE/ST=Bolivar/L=Upata/O=VenenuX/OU=Systemas:hozYmartillo/CN=$(hostname -d)&amp;quot; \&lt;br /&gt;
   -keyout /etc/ssl/certs/$(hostname -d).pem -out /etc/ssl/certs/$(hostname -d).pem&lt;br /&gt;
&lt;br /&gt;
chmod 640 /etc/ssl/certs/$(hostname -d).pem&lt;br /&gt;
&lt;br /&gt;
cat &amp;gt; /etc/lighttpd/mod_ssl.conf &amp;lt;&amp;lt; EOF&lt;br /&gt;
server.modules += (&amp;quot;mod_openssl&amp;quot;)&lt;br /&gt;
\$SERVER[&amp;quot;socket&amp;quot;] == &amp;quot;0.0.0.0:443&amp;quot; {&lt;br /&gt;
	ssl.engine  = &amp;quot;enable&amp;quot;&lt;br /&gt;
	ssl.pemfile = &amp;quot;/etc/ssl/certs/$(hostname -d).pem&amp;quot;&lt;br /&gt;
	ssl.cipher-list = &amp;quot;ECDHE-RSA-AES256-SHA384:AES256-SHA256:RC4:HIGH:!MD5:!aNULL:!EDH:!AESGCM&amp;quot;&lt;br /&gt;
	ssl.honor-cipher-order = &amp;quot;enable&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
\$HTTP[&amp;quot;scheme&amp;quot;] == &amp;quot;http&amp;quot; {&lt;br /&gt;
    url.redirect = (&amp;quot;&amp;quot; =&amp;gt; &amp;quot;https://\${url.authority}\${url.path}\${qsa}&amp;quot;)&lt;br /&gt;
    url.redirect-code = 308&lt;br /&gt;
}&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
sed -i -r &#039;s#\#.*mod_redirect.*,.*#    &amp;quot;mod_redirect&amp;quot;,#g&#039; /etc/lighttpd/lighttpd.conf&lt;br /&gt;
&lt;br /&gt;
checkssl=&amp;quot;&amp;quot;;checkssl=$(grep &#039;include &amp;quot;mod_ssl.conf&#039; /etc/lighttpd/lighttpd.conf);[[ &amp;quot;$checkssl&amp;quot; != &amp;quot;&amp;quot; ]] &amp;amp;&amp;amp; echo listo || sed -i -r &#039;s#.*include &amp;quot;mime-types.conf&amp;quot;.*#include &amp;quot;mime-types.conf&amp;quot;\ninclude &amp;quot;mod_ssl.conf&amp;quot;#g&#039; /etc/lighttpd/lighttpd.conf&lt;br /&gt;
&lt;br /&gt;
rc-service lighttpd restart&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For deploy usage of Lets Encrypt without chain-tools (just add water) read [https://wiki.lighttpd.net/HowToSimpleSSL HowToSimpleSSL].&lt;br /&gt;
&lt;br /&gt;
== Lighttpd advanced ==&lt;br /&gt;
&lt;br /&gt;
Lighttpd has pretty good default settings, but a few might be tweaked if we need to respond to higher server loads.&lt;br /&gt;
&lt;br /&gt;
[https://wiki.lighttpd.net/Docs_ResourceTuning lighttpd resource tuning]&lt;br /&gt;
&lt;br /&gt;
=== Lighttpd tunning for aggressive load ===&lt;br /&gt;
&lt;br /&gt;
[https://wiki.lighttpd.net/Docs_Performance lighttpd performance tuning]&lt;br /&gt;
&lt;br /&gt;
=== More connections, More File Descriptors ===&lt;br /&gt;
&lt;br /&gt;
This must be used with caution.  Everything is a file to a UNIX operating system. Well, every time a visitor accesses a page, lighttpd uses three file descriptors: An IP socket to the client, a FastCGI process socket, and a filehandle for the document accessed. Lighttpd stops accepting new connections when 90% of the available sockets are in use, restarting again when usage has fallen to 80%. With the default setting of 1024 file descriptors, lighttpd can handle a maximum of 307 connections. If this number are exceded file descriptor must be increrased then. This are a delicate tune due must be check your default with &amp;lt;code&amp;gt;cat /proc/sys/fs/file-max&amp;lt;/code&amp;gt; and make sure it’s over 10,000:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;&lt;br /&gt;
checkset=&amp;quot;&amp;quot;;checkset=$(grep &#039;max-fds&#039; /etc/lighttpd/lighttpd.conf);[[ &amp;quot;$checkset&amp;quot; != &amp;quot;&amp;quot; ]] &amp;amp;&amp;amp; echo listo || sed -i -r &#039;s#server settings.*#server settings\nserver.max-fds = 2048\n#g&#039; /etc/lighttpd/lighttpd.conf&lt;br /&gt;
&lt;br /&gt;
rc-service lighttpd restart&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== HTTP Keep-Alive for aggressive load ===&lt;br /&gt;
&lt;br /&gt;
One reason that file descriptors get used up so quickly is HTTP keep-alive. To improve performance, modern web servers keep client connections alive to handle multiple requests instead of building up and tearing down connections for each item in a page. Keep-alive is tremendously beneficial to performance, but tends to keep unnecessary connections alive, too. lighttpd allows 1000 keep-alive requests per connection, allows idle sessions to remain alive for 5 seconds, and gives reads and writes 1 minute and 6 minutes to complete, respectively.&lt;br /&gt;
&lt;br /&gt;
# Maximum number of request within a keep-alive session before the server terminates the connection, default = 1000 (&amp;lt;code&amp;gt;server.max-keep-alive-requests&amp;lt;/code&amp;gt;)&lt;br /&gt;
# Maximum number of seconds until an idling keep-alive connection is dropped, default = 5 (&amp;lt;code&amp;gt;server.max-keep-alive-idle&amp;lt;/code&amp;gt;)&lt;br /&gt;
# Maximum number of seconds until a waiting, non keep-alive read times out and closes the connection, default = 60 (&amp;lt;code&amp;gt;server.max-read-idle&amp;lt;/code&amp;gt;)&lt;br /&gt;
# Maximum number of seconds until a waiting write call times out and closes the connection, default = 360 (&amp;lt;code&amp;gt;server.max-write-idle&amp;lt;/code&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
Although lighttpd has pretty aggressive defaults (especially compared to Apache), a period of heavy traffic and a few slow clients could see many unused connections sticking around. The server.max-keep-alive-idle setting default of 5 seconds can be reduced to as low as 2, if you assume your clients are reasonably quick about requesting data, but a value of 3 or 4 is probably realistic. You may want to increase the server.max-keep-alive-requests value from the default of 1000, but you probably don’t need to. The server.max-read-idle and server.max-write-idle settings are tempting targets, but these situations are usually fairly rare so let’s not monkey with them.&lt;br /&gt;
&lt;br /&gt;
=== Lighttpd_Advanced_security ===&lt;br /&gt;
&lt;br /&gt;
See at [[Lighttpd_Advanced_security]] wiki page.&lt;br /&gt;
&lt;br /&gt;
=== Lighttpd and PHP with fpm ===&lt;br /&gt;
&lt;br /&gt;
In production web, LAMP means &#039;&#039;&#039;L&#039;&#039;&#039;inux + &#039;&#039;&#039;A&#039;&#039;&#039;pache + &#039;&#039;&#039;M&#039;&#039;&#039;ysql + &#039;&#039;&#039;P&#039;&#039;&#039;hp installed and integrated, but today the &amp;quot;A&amp;quot; of apache are more used as Nginx or Lighttpd, and the &amp;quot;M&amp;quot; of MySQL are more used as Mariadb, the LAMP focused documents are:&lt;br /&gt;
&lt;br /&gt;
* LAMP deploy of the Web Server with PHP, user html_dir and MariaDB: [[Production LAMP system: Lighttpd + PHP + MySQL]]&lt;br /&gt;
* LAMP deploy of the Web Server with PHP 5.6 and MariaDB: [[Production LAMP system: Lighttpd + PHP5 + MySQL]]&lt;br /&gt;
&lt;br /&gt;
= See Also =&lt;br /&gt;
&lt;br /&gt;
* [[Production LAMP system: Lighttpd + PHP + MySQL]]&lt;br /&gt;
* [[Alpine newbie developer]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Newbie]]&lt;br /&gt;
[[Category:Server]]&lt;br /&gt;
[[Category:Web_Server]]&lt;br /&gt;
[[Category:Monitoring]]&lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
[[Category:Security]]&lt;br /&gt;
[[Category:Production]]&lt;/div&gt;</summary>
		<author><name>Gstrauss</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Lighttpd&amp;diff=18325</id>
		<title>Lighttpd</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Lighttpd&amp;diff=18325"/>
		<updated>2020-12-22T03:33:28Z</updated>

		<summary type="html">&lt;p&gt;Gstrauss: lighttpd 1.4.56 and later support HTTP/2; improve English language phrasing&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
Its name is a portmanteau of &amp;quot;light&amp;quot; and &amp;quot;httpd&amp;quot;: [http://www.lighttpd.net/ lighttpd] is a simple, standards-compliant, secure, and flexible web server. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;lighttpd is a powerful server, made long ago to handle upwards of 10,000 connections in parallel on one server&#039;&#039;&#039;. It was used in wikipedia server a log time ago and also some google services.&lt;br /&gt;
&lt;br /&gt;
{{Note|As for minimal sites and quick-start purposes, it is recommended due to its easy configuration process and excellent performance without much configuration. Check https://w3techs.com/technologies/details/ws-lighttpd and note that it is used in high traffic and important sites like postgresql.org}}&lt;br /&gt;
&lt;br /&gt;
== General information ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Feature/Artifact !! Value/Name !! Observations&lt;br /&gt;
|-&lt;br /&gt;
| Main package name || lighttpd || &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;apk add lighttpd&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Manpages and DOCs packages || lighttpd-doc || &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;apk add lighttpd-doc&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| Configuration file || {{Path|/etc/lighttpd/lighttpd.conf}} || A vanilla default configuration&lt;br /&gt;
|-&lt;br /&gt;
| Html place for system pages || {{Path|/var/www/localhost/htdocs/}} || Each web server in alpine has own path for that&lt;br /&gt;
|-&lt;br /&gt;
| Dynamic files (cache, extra) || {{Path|/var/lib/lighttpd/}} || Created dynamically, each server in alpine has own path for that&lt;br /&gt;
|-&lt;br /&gt;
| Log files (error, access, etc) || {{Path|/var/log/lighttpd/}} || Each web server in alpine has own path for that&lt;br /&gt;
|-&lt;br /&gt;
| User running the webserver || lighttpd || Others Linux used &amp;quot;www-data&amp;quot; alpine has as a group&lt;br /&gt;
|-&lt;br /&gt;
| Group to common to webserver || www-data || Used to share things amont others daemons or services, like redis or apache files&lt;br /&gt;
|-&lt;br /&gt;
| Programed on || C and lua || Main engine code in C, modules and config in Lua variants&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==== Important Limitations ====&lt;br /&gt;
&lt;br /&gt;
Some common hosting panels do not handle {{Pkg|lighttpd}} configuration management.&lt;br /&gt;
&lt;br /&gt;
No HTTP/3 support.&lt;br /&gt;
&lt;br /&gt;
As we read previously.. main purpose was handle several request on one server, so are focused on high load. &lt;br /&gt;
&lt;br /&gt;
As main front end web server are perfect and it&#039;s &#039;&#039;&#039;recommended as reverse proxy server for {{Pkg|apache2}} or {{Pkg|nginx}}&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Install Lighttpd ==&lt;br /&gt;
&lt;br /&gt;
The installation works just out of the box for only static pages, just with install you can see webserver in action by put any file inside the  {{Path|/var/www/localhost/htdocs/}} directory.&lt;br /&gt;
&lt;br /&gt;
Per user web files are supported by default in  {{Path|/home/&amp;lt;user&amp;gt;/public_html}} directory by default if we enable it (process are described below in further section &amp;quot;Lighttpd configuration&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
{{Pkg|lighttpd}} is available in the Alpine Linux repositories. To install, simple launch the commands below:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;&lt;br /&gt;
apk add lighttpd&lt;br /&gt;
&lt;br /&gt;
rc-update add lighttpd default&lt;br /&gt;
&lt;br /&gt;
rc-service lighttpd restart&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Testing Lighttpd ==&lt;br /&gt;
&lt;br /&gt;
This section is assuming that lighttpd is running. If you now launch a web browser from a remote system and point it to your web server, you will see a page that says &amp;quot;404 - Not Found&amp;quot;. Well, at the moment there is no content available but the server is up and running.&lt;br /&gt;
&lt;br /&gt;
Let&#039;s add a simple test page to get rid of the &amp;quot;404 - Not Found page&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|echo &amp;quot;Lighttpd is running...&amp;quot; &amp;gt; /var/www/localhost/htdocs/index.html}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;For testing open a browser and go to &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;http://127.0.0.1/&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; and you will see &amp;quot;Lighttpd is running...&amp;quot;&#039;&#039;&#039;. Note that we used &amp;quot;127.0.0.1&amp;quot; if you are using alpine as the only machine for all as your main desktop/pc/machine.&lt;br /&gt;
&lt;br /&gt;
If you are using alpine remotelly as web server and just install it the package, &#039;&#039;&#039;open a browser in your desktop machine, and go to &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;http://&amp;lt;webserveripaddres&amp;gt;/&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;. The &amp;quot;webserveripaddres&amp;quot; are the ip address of your setup/server machine.&lt;br /&gt;
&lt;br /&gt;
== Lighttpd Configuration ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;If you just want to serve simple HTML pages lighttpd can be used out-of-box. No further configuration needed.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
For production purposes the [[Production LAMP system: Lighttpd + PHP + MySQL]] wiki page will explain in details all the needs, there&#039;s the [[Production Lets Encrypt: dehydrated]] wiki page with futher information to use HTTPS and lets encrypt certificates.&lt;br /&gt;
&lt;br /&gt;
Due to the minimalism of alpine linux, &#039;&#039;&#039;unfortunately the lighttpd packaging only provided vanilla configurations not close to alpine or easy admin maintenance&#039;&#039;&#039;, see the [[Production LAMP system: Lighttpd + PHP + MySQL]] wiki page to goin in deep about configuring lighttpd web server.&lt;br /&gt;
&lt;br /&gt;
==== Controlling Lighttpd ====&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Start lighttpd&#039;&#039;&#039;&#039;&#039;: After the installation {{Pkg|lighttpd}} is not running. As we made in first section was started already but if you want to start {{Pkg|lighttpd}} manually use:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|rc-service lighttpd start}}&lt;br /&gt;
&lt;br /&gt;
You will get a feedback about the status.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 * Caching service dependencies                                 [ ok ]&lt;br /&gt;
 * Starting lighttpd...                                         [ ok ]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Stop lighttpd&#039;&#039;&#039;&#039;&#039;: If you want to stop the web server use &#039;&#039;stop&#039;&#039; in the same way of previous command:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|rc-service lighttpd stop}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Restart lighttpd&#039;&#039;&#039;&#039;&#039;: After changing the configuration file lighttpd needs to be restarted.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|rc-service lighttpd restart}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;Proper Runlevel&#039;&#039;&#039;&#039;&#039;: By default no services are added to start process, sysadmin must know what we want and what will services do, also other main reason are due in dockers there&#039;s no runlevels per se and Alpine linux are mostly used in dockers containers. You must added the servide only to the default runlevel, not to boot, because need networking activated&lt;br /&gt;
&lt;br /&gt;
{{Cmd|rc-update add lighttpd default}}&lt;br /&gt;
&lt;br /&gt;
= See Also =&lt;br /&gt;
&lt;br /&gt;
In production web, LAMP means &#039;&#039;&#039;L&#039;&#039;&#039;inux + &#039;&#039;&#039;A&#039;&#039;&#039;pache + &#039;&#039;&#039;M&#039;&#039;&#039;ysql + &#039;&#039;&#039;P&#039;&#039;&#039;hp installed and integrated, but today the &amp;quot;A&amp;quot; of apache are more used as Nginx or Lighttpd, and the &amp;quot;M&amp;quot; of MySQL are more used as Mariadb, the LAMP focused documents are:&lt;br /&gt;
&lt;br /&gt;
* [[Setting_Up_Lighttpd_with_PHP|Setting Up Lighttpd with PHP]] &lt;br /&gt;
* [[Lighttpd Advanced security]] &lt;br /&gt;
* [[Production Lets Encrypt: dehydrated]]&lt;br /&gt;
* LAMP deploy of the Web Server with PHP, user html_dir and MariaDB: [[Production LAMP system: Lighttpd + PHP + MySQL]]&lt;br /&gt;
* LAMP deploy of the Web Server with PHP 5.6 and MariaDB: [[Production LAMP system: Lighttpd + PHP5 + MySQL]]&lt;br /&gt;
* [[Alpine newbie developer]]&lt;br /&gt;
* [[Alpine newbie lammers]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Newbie]]&lt;br /&gt;
[[Category:Server]]&lt;br /&gt;
[[Category:Web_Server]]&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Gstrauss</name></author>
	</entry>
</feed>