INSTALLING LIGHTTPD on CentOS 6.2

** lighttpd_logo Here is a simple guide to set up a working LIGHTTPD web server on CentOS 6.2 server. let’s get started.. CONFIGURATION:php

Step 1: make sure you have connectivity! And DNS resolution!html

[root@localhost]# ping 8.8.8.8 PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data. 64 bytes from 8.8.8.8: icmp_seq=1 ttl=45 time=45.9 mspython

[root@localhost]# ping www.google.it PING www-cctld.l.google.com (173.194.35.151) 56(84) bytes of data. 64 bytes from muc03s01-in-f23.1e100.net (173.194.35.151): icmp_seq=1 ttl=51 time=48.9 msweb

Step 2: install the packages ZLIB data compression library and PCRE 「Perl-compatible regular expression library」express

[root@localhost]# yum install zlib zlib-devel pcre pcre-develide

Add the repository with the following:ui

rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpmthis

Install Lighty!google

Yum install lighttpd.net

Set boot properties

Chkconfig –levels 235 lighttpd on

And start the service

Service lighttpd start

!! IF ERROR COMES UP !! like this one:

Starting lighttpd: XX:DATE:XX:TIME:XX: (server.c.722) couldn't set 'max filedescriptors' Permission denied [FAILED]

Correct doing the following :

[root@localhost]# yum install policycoreutils-python

[root@localhost]# semodule -DB [root@localhost]# /etc/init.d/auditd restart Stopping auditd:[ OK ] Starting auditd:[ OK ] [root@localhost]# /etc/init.d/lighttpd restart Stopping lighttpd:[FAILED] Starting lighttpd: XX:DATE:XX:TIME:XX: (server.c.722) couldn't set 'max filedescriptors' Permission denied [FAILED] [root@localhost]# grep lighttpd /var/log/audit/audit.log | audit2allow -M lighttpdmaxfds [root@localhost]# semodule -i lighttpdmaxfds.pp [root@localhost]# /etc/init.d/lighttpd start Starting lighttpd:[ OK ] [root@localhost]# /usr/sbin/semodule –B

Ok now Lighttpd is up & running, let’s see the main directories: Web pages document root: /srv/www/lighttpd/ Config file: /etc/lighttpd/lighttpd.conf Module library: /usr/lib/lighttpd/ Log files: /var/log/lighttpd/ Save default configuration:

[root@localhost lighttpd]# cp lighttpd.conf lighttpd.def.conf [root@localhost lighttpd]# cp modules.conf modules.def.conf [root@localhost lighttpd]# Nano modules.conf

server.modules = (
  "mod_access",
#  "mod_alias",
#  "mod_auth",
#  "mod_evasive",
#  "mod_redirect",
#  "mod_rewrite",
#  "mod_setenv",
#  "mod_usertrack",
  "mod_accesslog"   )     ## <-- add this line」

Step into lighttpd.conf file and modify this lines (open with nano and just hit ctrl+w to search in the file) (install nano editor with yum install nano if nano is not present)

server.port = 3000 server.pid-file = "/var/run/lighttpd.pid"

server.document-root = "/srv/www/lighttpd/"

server.errorlog = "/var/log/lighttpd/error_log"

make sure this lines are present (or modify with your needs)

index-file.names = ( "index.html", "index.htm", "default.htm" ) static-file.exclude-extensions = ( ".php", ".pl", ".fcgi", "~", ".inc" )

go to /conf.d folder and modify access_log.conf with the following line:

accesslog.filename = "/var/log/lighttpd/access_log"

Check syntax, restart the service and write a simple 「hello world」 index file:

[root@localhost lighttpd]# lighttpd -t -f lighttpd.conf Syntax OK

[root@localhost lighttpd]# service lighttpd start Starting lighttpd: [ OK ] [root@localhost lighttpd]# service lighttpd restart Stopping lighttpd: [ OK ] Starting lighttpd: [ OK ]

[root@localhost lighttpd]# cd /srv/www/lighttpd/ [root@localhost lighttpd]# ls [root@localhost lighttpd]# nano index.html Hello World!

^X y

[root@localhost lighttpd]#

Now navigate to the webserver IP with any browser you should able to see the message. Thanks.**

相關文章
相關標籤/搜索