OSETC TECH

CentOS /RHEL: How To Setup Lighttpd Web Server

I would like to setup lighttpd web server on my centos or rhel system. How Do I setup lighttpd web service under centos or RHEL operating system. How to install/configure lighttpd server. you’ll see that the steps how to setup lighttpd web server in this post.

Security, speed, compliance, and flexibility — all of these describe lighttpd (pron. lighty) which is rapidly redefining efficiency of a webserver; as it is designed and optimized for high performance environments. With a small memory footprint compared to other web-servers, effective management of the cpu-load, and advanced feature set (FastCGI, SCGI, Auth, Output-Compression, URL-Rewriting and many more) lighttpd is the perfect solution for every server that is suffering load problems.

CentOS Install Epel Repo


As lighttpd package is not included in CentOS yum repository, so you need to install Epel repository to install lighttpd package.

Download Epel Repo

Using the wget command to download epel package so that to install it.

wget http://epel.mirror.net.in/epel/6/i386/epel-release-6-8.noarch.rpm

outputs:

Resolving epel.mirror.net.in... 120.88.47.14, 2401:4800:2121:c0:ff:ee:ee:2

Connecting to epel.mirror.net.in|120.88.47.14|:80... connected.

HTTP request sent, awaiting response... 200 OK

Length: 14540 (14K) [application/x-redhat-package-manager]

Saving to: “epel-release-6-8.noarch.rpm”

100%[==========================================================================================>] 14,540      54.6K/s   in 0.3s

2014-02-23 12:24:53 (54.6 KB/s) - “epel-release-6-8.noarch.rpm” saved [14540/14540]

Install epel repo package 

issue the following command:

rpm -ivh epel-release-6-8.noarch.rpm

outputs:

arning: epel-release-6-8.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY

Preparing...                ########################################### [100%]

  1:epel-release           ########################################### [100%]

CentOS Setup lighttpd web server


Step1# using the following command to install lighttpd packages

yum install lighttpd lighttpd-fastcgi lighttpd-mod_geoip

outputs:

Loaded plugins: downloadonly, fastestmirror, security

Loading mirror speeds from cached hostfile

 * base: mirror.thelinuxfix.com

 * epel: mirror.steadfast.net

 * extras: holmes.umflint.edu

 * updates: bay.uchicago.edu

Setting up Install Process

Resolving Dependencies

--> Running transaction check

---> Package lighttpd.x86_64 0:1.4.34-1.el6 will be installed

---> Package lighttpd-fastcgi.x86_64 0:1.4.34-1.el6 will be installed

--> Processing Dependency: spawn-fcgi for package: lighttpd-fastcgi-1.4.34-1.el6.x86_64

---> Package lighttpd-mod_geoip.x86_64 0:1.4.34-1.el6 will be installed

--> Processing Dependency: libGeoIP.so.1()(64bit) for package: lighttpd-mod_geoip-1.4.34-1.el6.x86_64

--> Running transaction check

---> Package GeoIP.x86_64 0:1.4.8-1.el6 will be installed

---> Package spawn-fcgi.x86_64 0:1.6.3-1.el6 will be installed

--> Finished Dependency Resolution

Dependencies Resolved
======================================================================

 Package                Arch       Version             Repository
                                                           Size

======================================================================

Installing:

 lighttpd               x86_64     1.4.34-1.el6        epel     294 k

 lighttpd-fastcgi       x86_64     1.4.34-1.el6        epel      44 k

 lighttpd-mod_geoip     x86_64     1.4.34-1.el6        epel      21 k

Installing for dependencies:

 GeoIP                  x86_64     1.4.8-1.el6         epel     620 k

 spawn-fcgi             x86_64     1.6.3-1.el6         epel      16 k
Transaction Summary

======================================================================

Install       5 Package(s)
Total download size: 995 k

Installed size: 2.4 M

Is this ok [y/N]: y

Downloading Packages:

(1/5): GeoIP-1.4.8-1.el6.x86_64.rpm            | 620 kB     00:00

(2/5): lighttpd-1.4.34-1.el6.x86_64.rpm        | 294 kB     00:00

(3/5): lighttpd-fastcgi-1.4.34-1.el6.x86_64.rp |  44 kB     00:00

(4/5): lighttpd-mod_geoip-1.4.34-1.el6.x86_64. |  21 kB     00:00

(5/5): spawn-fcgi-1.6.3-1.el6.x86_64.rpm       |  16 kB     00:00

----------------------------------------------------------------------

Total                                 1.7 MB/s | 995 kB     00:00

warning: rpmts_HdrFromFdno: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY

Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

Importing GPG key 0x0608B895:

 Userid : EPEL (6) <epel@fedoraproject.org>

 Package: epel-release-6-8.noarch (installed)

 From   : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

Is this ok [y/N]: y

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

Warning: RPMDB altered outside of yum.

  Installing : lighttpd-1.4.34-1.el6.x86_64                       1/5

  Installing : GeoIP-1.4.8-1.el6.x86_64                           2/5

  Installing : spawn-fcgi-1.6.3-1.el6.x86_64                      3/5

  Installing : lighttpd-fastcgi-1.4.34-1.el6.x86_64               4/5

  Installing : lighttpd-mod_geoip-1.4.34-1.el6.x86_64             5/5

  Verifying  : lighttpd-1.4.34-1.el6.x86_64                       1/5

  Verifying  : lighttpd-mod_geoip-1.4.34-1.el6.x86_64             2/5

  Verifying  : spawn-fcgi-1.6.3-1.el6.x86_64                      3/5

  Verifying  : GeoIP-1.4.8-1.el6.x86_64                           4/5

  Verifying  : lighttpd-fastcgi-1.4.34-1.el6.x86_64               5/5

Installed:

  lighttpd.x86_64 0:1.4.34-1.el6

  lighttpd-fastcgi.x86_64 0:1.4.34-1.el6

  lighttpd-mod_geoip.x86_64 0:1.4.34-1.el6

Dependency Installed:

  GeoIP.x86_64 0:1.4.8-1.el6      spawn-fcgi.x86_64 0:1.6.3-1.el6
Complete!

Start lighttpd service 

Type the following command:

service lighttpd start

Step2# edit lighttpd configuration file

You need to edit the lighttpd configuration file located in “/etc/lighttpd/lighttpd.conf“, updated the below content:

var.server_root = "/var/www"

include "modules.conf"

server.port = 80

server.document-root = server_root + "/lighttpd"

uncomment the below modules:

include "conf.d/fastcgi.conf"

server.modules = (

  "mod_access",

  "mod_alias",

  "mod_auth",

#  "mod_evasive",

 "mod_redirect",

  "mod_rewrite",

#  "mod_setenv",

#  "mod_usertrack",

Step3# restart lighttpd service

Type the following command:

service lighttpd restart

done….