---
title: "RHEL as 4 环境下安装 lighttpd"
author: "wang_let"
date: "2008-12-25T11:40:39Z"
tags: []
slug: "rhel-as-4-lighttpd"
draft: false
lastmod: "2008-12-25T11:40:39Z"
id: 301316
url: "https://wang-let.iteye.com/blog/301316"
---

在参考Robbin"在 Linux 平台上安装和配置 Ruby on Rails 详解 "后,在RHEL环境下进行了尝试,并配置成功.

step 1:检查系统是否安装了支持库 pcre
# rpm -qa|grep pcre
pcre-4.5-4.el4_5.1

问题:我的系统提示安装过,但是因为版本问题,无法安装LIGHTTPD,因此重新下载并安装PCRE

在/usr/local/src/下
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-7.6.tar.gz

解压缩
tar xzvf pcre-7.6.tar.gz
生成 pcre-7.6 目录并进入该目录
配置&编译 pcre
./configure 
make
make clean
make install

支持库安装完成

step 2:安装lighttpd
首先在/usr/local/src/下下载lighttpd原文件
wget http://www.lighttpd.net/download/lighttpd-1.4.20.tar.gz
解压缩

tar xzvf lighttpd-1.4.20.tar.gz 生成lighttpd-1.4.20目录，进入该目录
编译：./configure --prefix=/usr/local/lighttpd
configure完毕以后，会给出一个激活的模块和没有激活模块的清单，可以检查一下，是否自己需要的模块都已经激活，在enable的模块中一定要有“mod_rewrite”这一项，否则重新检查pcre是否安装。然后编译安装：
make && make clean && make install 

step 3 配置环境
编译后配置：之所以这么做，请查看doc/rc.lighttpd.redhat就明白了
cp doc/sysconfig.lighttpd /etc/sysconfig/lighttpd 
mkdir /etc/lighttpd 
cp doc/lighttpd.conf /etc/lighttpd/lighttpd.conf 
cp doc/rc.lighttpd.redhat /etc/init.d/lighttpd 

修改下列文件的下列内容
/etc/init.d/lighttpd，把
lighttpd=/usr/sbin/lighttpd 
改为
lighttpd=/usr/local/lighttpd/sbin/lighttpd 

该文件用于启动、停止LIGHTTD服务
此脚本用来控制lighttpd的启动关闭和重起：
/etc/init.d/lighttpd start 
/etc/init.d/lighttpd stop 
/etc/init.d/lighttpd restart 
 
如果你希望服务器启动的时候就启动lighttpd，那么：
chkconfig lighttpd on 

step 4:配置/usr/local/lighttpd.conf
主要要注意一下，server.document-root, server.error-log，accesslog.filename需要指定相应的目录，默认的情况下，有些目录或文件是不存在的，要建立。


完毕！！