Category Archives: Lighttpd

Password protect folder with Lighttpd and htpasswd

Enable mod_auth module in Lighttpd (/etc/lighttpd/lighttpd.conf) config file: server.modules = ( […] "mod_auth", )server.modules = ( […] "mod_auth", ) Inside the vhost config file write this: auth.backend = "htpasswd" auth.backend.htpasswd.userfile = "/path/to/file/.htpasswd" auth.require = ( "/folder-to-protect/" => ( "method" => "basic", "realm" => "Please enter your Password.", "require" => "valid-user" ), )auth.backend = "htpasswd" auth.backend.htpasswd.userfile […]

Lighttpd configure domain and subdomain

We have a domain “” and a subdomain “”. Create a file named “” in /etc/lighttpd/ directory: $HTTP["host"] =~ "(^www\.example\.com|^example\.com)" { server.document-root = "/var/www/" server.errorlog = "/var/www/" accesslog.filename = "/var/www/" }$HTTP["host"] =~ "(^www\.example\.com|^example\.com)" { server.document-root = "/var/www/" server.errorlog = "/var/www/" accesslog.filename = "/var/www/" } Create a file named “” in /etc/lighttpd/ directory: $HTTP["host"] == "" […]

Lighttpd rewrite rules for WordPress sites

Rewrite rules compatible with WordPress permalinks: # Handle 404 errors server.error-handler-404 = "/index.php"   # Rewrite rules url.rewrite-final = (   # Exclude some directories from rewriting "^/(wp-admin|wp-includes|wp-content|gallery2)/(.*)" => "$0",   # Exclude .php files at root from rewriting "^/(.*.php)" => "$0",   # Handle permalinks and RSS feeds "^/(.*)$" => "/index.php/$1" ) # Handle […]

Lighttpd server handler 404 error

When a document is not found, Lighttpd redirects users to a static HTML web page: If you want to redirect users to a web page with dynamic content (recommended), you need to take in mind that by default Lighttpd returns a 200 OK HTTP status, so you need to set the HTTP headers to 404 […]

Lighttpd log file rotation with logrotate

Open and edit the file located here: /etc/logrotate.d/lighttpd/etc/logrotate.d/lighttpd You should see something like this: /var/log/lighttpd/*.log { daily missingok copytruncate rotate 12 compress delaycompress dateformat -%Y-%m-%d dateext notifempty sharedscripts postrotate if [ -x /usr/sbin/invoke-rc.d ]; then \ invoke-rc.d lighttpd reopen-logs > /dev/null 2>&1; \ else \ /etc/init.d/lighttpd reopen-logs > /dev/null 2>&1; \ fi; \ endscript }/var/log/lighttpd/*.log […]

Lighttpd error: sockets disabled, connection limit reached

To fix this error message: [note] sockets disabled, connection limit reached[note] sockets disabled, connection limit reached You need to increase the max-fds and max-connections limit. Add these lines in the lighttpd.conf file: server.max-fds = 8192 server.max-connections = 4096server.max-fds = 8192 server.max-connections = 4096 Restart Lighttpd: /etc/init.d/lighttpd restart/etc/init.d/lighttpd restart Now type: cat /proc/`ps ax | grep […]

Verify Lighttpd Web Server Config File

Type this command to verify the Lighttpd config file: lighttpd -p -f /etc/lighttpd/lighttpd.conflighttpd -p -f /etc/lighttpd/lighttpd.conf It can help you find old values loaded by Lighttpd.

Install Lighttpd + MySQL + PHP5-CGI on Debian

In my opinion, Lighttpd + PHP5-CGI is the best arsenal for high traffic websites. Install the needed packages: apt-get install mysql-server lighttpd php5-cgi php5-mysqlapt-get install mysql-server lighttpd php5-cgi php5-mysql The default WWW path for Lighttpd is: /var/www//var/www/ The configuration file is located here: /etc/lighttpd/lighttpd.conf/etc/lighttpd/lighttpd.conf Edit the php.ini file: vi /etc/php5/cgi/php.inivi /etc/php5/cgi/php.ini And uncomment: […] cgi.fix_pathinfo […]

WARNING: unknown config-key: accesslog.filename (ignored)

To fix this error message: WARNING: unknown config-key: accesslog.filename (ignored)WARNING: unknown config-key: accesslog.filename (ignored) You need to enable mod_accesslog module, edit the Lighttpd config file: vi /etc/lighttpd/lighttpd.confvi /etc/lighttpd/lighttpd.conf Add “mod_accesslog” in the list of loaded modules, example: server.modules = ( "mod_access", "mod_accesslog", "mod_alias", "mod_compress", "mod_redirect", "mod_rewrite", "mod_fastcgi", )server.modules = ( "mod_access", "mod_accesslog", "mod_alias", "mod_compress", "mod_redirect", […]