Configure And Install Lighttpd Server On CentOS

install-lighttpd
mm
Written By:- Santosh Prasad

Lighttpd server is very light web server. It is open source web server. It can handle large number of traffic using less memory and low cpu usage, as it is used  for high performance environments.  Secure,  fast, flexible and compliance is the advance feature of this web server. Also well know as “lighty” . We can also install it on Windows server.

In this tutorial I will explain, how to setup lighttpd web server on CentOS release 6.7 (Final).

Installing lighttpd on CentOS

I am going to install lighttpd using Package Manager. It is easy way to install any package.

So we will run the following command with sudo or root permission. Lighttpd is not available in Centos default repository. We will install it from edition EPEL repository on Centos server . To install it run the following command.

Using Yum:

# yum install epel-release

Loaded plugins: fastestmirror
Setting up Install Process
Loading mirror speeds from cached hostfile
epel/metalink                                                                                                                                    |  13 kB     00:00
* base: repo1.dal.innoscale.net
* epel: fedora-epel.mirror.lstn.net
* extras: mirror.nexcess.net
* updates: repos.dfw.quadranet.com
* webtatic: us-east.repo.webtatic.com

base                                                                                                                                             | 3.7 kB     00:00
epel                                                                                                                                             | 4.3 kB     00:00
epel/primary_db                                                                                                                                  | 5.9 MB     00:00
extras                                                                                                                                           | 3.4 kB     00:00
mysql-connectors-community                                                                                                                       | 2.5 kB     00:00
mysql-tools-community                                                                                                                            | 2.5 kB     00:00
mysql56-community                                                                                                                                | 2.5 kB     00:00
updates                                                                                                                                          | 3.4 kB     00:00
webtatic                                                                                                                                         | 3.6 kB     00:00
Package epel-release-6-8.noarch already installed and latest version Nothing to do.

Using RPM:

CentOS/Redhat 6 32-Bit

# wget http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
# rpm -ivh epel-release-6-8.noarch.rpm
warning: epel-release-6-8.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Preparing... ########################################### [100%]
1:epel-release ########################################### [100%]

CentOS/Redhat 6 64-Bit

# wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm -ivh epel-release-6-8.noarch.rpm

After that we will update your system before installing lighttpd.

#yum update
#yum install lighttpd
lighttpd2

Installing lighttpd on Ubuntu

We can also install lighttpd from Ubuntu official repository. To install lighttpd from Ubuntu official, we will need to update it first than install using below command.

# apt-get update
# apt-get install lighttpd

Installing lighttpd from source

Here we can also install lighttpd latest version from source.  To install lighttpd on system first we’ll need to download it.  After download lighttpd package we’ll compile it into our system.

Please install all dependency which is require to compile.

Downloading  lighttpd package.

# mkdir /root/download
# cd /root/download
# wget http://download.lighttpd.net/lighttpd/releases-1.4.x/lighttpd-1.4.39.tar.gz

–2016-11-17 04:08:03– http://download.lighttpd.net/lighttpd/releases-1.4.x/lighttpd-1.4.39.tar.gz
Resolving download.lighttpd.net… 188.40.103.19, 2a01:4f8:100:8082::2
Connecting to download.lighttpd.net|188.40.103.19|:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: 874931 (854K) [application/x-gtar-compressed]
Saving to: `lighttpd-1.4.39.tar.gz’
00%[=======================================================>]874,931 221K/s in 3.9s
2016-11-17 04:08:09 (221 KB/s) – `lighttpd-1.4.39.tar.gz’ saved [874931/874931]

After downloaded  we’ll need to un-tar downloaded package using below command.

# tar -zxvf lighttpd-1.4.39.tar.gz

Than we will compile package using below command.

# cd lighttpd-1.4.39
# ./configure
# make#make install

Please Note : Here I am explaining about lighttpd standard installation. If you want to install its advance features like mod_rewrite, mode_redirect and secure connection (SSL). You can configure it according to meet your requirement.

Lets’ move ahead for its configuration part.

Lighttpd Configuration

The default lighttpd configuration file located at ” /etc/lighttpd/lighttpd.conf”.  I am going to change only default webroot director “ /var/www/lighttpd/ “ to  “/var/www/vhost/ “.  You can also change webroot directory as per the requirement. Here am going to change it to “/var/www/vhost”.

#mkdir /var/www/vhost
#cd /var/www/vhost
#vim index.html

WELCOME TO LOOKLINUX.COM

Save and exit.

After creating webroot directoy. We will made some changes in “/etc/lighttpd/lighttpd.conf”  file. So that lighttpd look at your crated “/var/www/vhost “ directory.

# vim /etc/lighttpd/lighttpd.conf

## Document root
#server.document-root = server_root + "/lighttpd"
#Comment out default Document root to your costume created directory like below.
server.document-root = server_root + "/vhost"

Save and exit.

Than start your lighttpd service.

#/etc/init.d/lighttpd start
Stopping lighttpd: [ OK ]
Starting lighttpd: 2016-11-17 04:50:31: (network.c.272) warning: please use server.use-ipv6 only for hostnames, not without server.bind / empty address; your config will break if the kernel default for IPV6_V6ONLY changes2016-11-17 04:50:31: (server.c.1176) can't have more connections than fds/2: 1024 1024 [ OK ]

Here you can see warning during starting lighttpd service.  You can fix it by editing  “lighttpd.conf

Find “server.use-ipv6” and change its value to “disable” like below.

# vim /etc/lighttpd/lighttpd.conf

## Use IPv6?
#server.use-ipv6 = "enable"

server.use-ipv6 = "disable"

##

Save and exit.

Start  lighttpd service again.

# service lighttpd restart

Stopping lighttpd: [ OK ]

Starting lighttpd: 2016-11-17 05:28:47: (server.c.1176) can't have more connections than fds/2: 1024 1024

[ OK ]

Again you may get error. You can fix it again editing  “lighttpd.conf”.

#vim /etc/lighttpd/lighttpd.conf

## With SELinux enabled, this is denied by default and needs to be allowed
## by running the following once : setsebool -P httpd_setrlimit on
#Uncomment and remove “#” below line
#server.max-fds = 2048
#To :-

server.max-fds = 2048

## listen-backlog is the size of the listen() backlog queue requested when##

That’s it . Finally check configuration file for any syntax error before start its service.

# lighttpd -t -f /etc/lighttpd/lighttpd.conf
Syntax OK

Again start lighttpd service.

# service lighttpd restart

Stopping lighttpd: [ OK ]
Starting lighttpd: [ OK ]

Test your page in your browse by typing your server IP and you should see your crated page “index.html”.

Access your lighttpd web server

lighttpd-img2

Please make sure port 80 should be open on firewall.

I hope this article will help to install and configure lighttpd on CentOS.

Thanks:)

About Author

mm

Santosh Prasad

Hi! I'm Santosh and I'm here to post some cool article for you. If you have any query and suggestion please comment in comment section.

Other Post by Santosh Prasad

Visit All Post

Related Article

You may also Like

Leave a Comment

Shares