| Lighttpd Gzip Compression To Improve Speed (mod_compress) |
|
|
|
| How To - Lighttpd | |||
| Written by Christian Foronda | |||
| Thursday, 08 April 2010 15:13 | |||
|
Lighttpd sipports gzip compression by using mod_compress module. The output compression reduces the network load and can improve the overall throughput of the webserver. Configuration Open your lighttpd configuration file: # vi /etc/lighttpd/lighttpd.conf Append the add mod_ compress to list of server modules: server.modules = ( "mod_compress" ) Setup compress.cache-dir to stored all cached file: compress.cache-dir = "/var/cache/lighttpd/compress/" Define mimetypes to get compressed: compress.filetype = ("text/plain", "text/html", "text/css", "text/xml", "text/javascript")
Save and close the file. Create /var/cache/lighttpd/compress directory: # mkdir -p /var/cache/lighttpd/compress # chown lighttpd:lighttpd /var/cache/lighttpd/compress Restart lighttpd: # /etc/init.d/lighttpd restart Enable mod_compress per virtaul host: Use conditional $HTTP host directive: $HTTP["host"] =~ "domain\.com" {
compress.cache-dir = "/var/cache/lighttpd/compress/domain.com/"
}
PHP dynamic compression Open php.in file:: # vi /etc/php.ini Enable following two directives: zlib.output_compression = On zlib.output_handler = On Save and close the file. Restart lighttpd: # /etc/init.d/lighttpd restart Cleaning cache directory Cleaning the cache is left to the user. A cron job deleting files older than 10 days could do it: # find /var/cache/lighttpd/compress -type f -mtime +10 | xargs -r rm Better yet, create and install a script at /etc/cron.daily directory.: #!/bin/bash
# Shell script to clean web server cache stored at /var/cache/lighttpd/compress/ directory.
# -------------------------------------------------------------------------
# Copyright (c) 2007 nixCraft project
# This script is licensed under GNU GPL version 2.0 or above
# -------------------------------------------------------------------------
# This script is part of nixCraft shell script collection (NSSC)
# Visit http://bash.cyberciti.biz/ for more information.
# -------------------------------------------------------------------------
# Cache dir path
CROOT="/var/cache/lighttpd/compress/"
#Deleting files older than 10 days
DAYS=10
# Lighttpd user and group
LUSER="lighttpd"
LGROUP="lighttpd"
# start cleaning
find ${CROOT} -type f -mtime +${DAYS} | xargs -r /bin/rm
# if directory missing just recreate it
if [ ! -d $CROOT ]
then
mkdir -p $CROOT
chown ${LUSER}:${LGROUP} ${CROOT}
fi
Reference: http://www.cyberciti.biz/tips/lighttpd-mod_compress-gzip-compression-tutorial.html Similar articles
|
|||
| Last Updated on Thursday, 08 April 2010 15:15 |


