安装必要的软件:
yum -y install glib2-devel openssl-devel pcre-devel bzip2-devel gzip-devel
yum -y install gamin
yum -y install gamin-devel
yum -y install gcc gcc-c++
安装Lighttpd: 到http://www.lighttpd.net/
下载最新版,现在最新版是1.4.28.
cd /usr/local/src
wget http://download.lighttpd.net/lighttpd/releases-1.4.x/lighttpd-1.4.28.tar.gz
tar -zxvf lighttpd-1.4.28.tar.gz
cd lighttpd-1.4.28
make clean && make distclean
./configure --with-fam
make
make install
配置Lighttpd:
sed -e 's/FOO/lighttpd/g' doc/rc.lighttpd.redhat > /etc/init.d/lighttpd
chmod 755 /etc/init.d/lighttpd
echo "LIGHTTPD_CONF_PATH=/etc/lighttpd/lighttpd.conf" > /etc/sysconfig/lighttpd
install -Dp ./doc/lighttpd.conf /etc/lighttpd/lighttpd.conf
chkconfig lighttpd on
创建符号链接:
ln -s /usr/local/sbin/lighttpd /usr/sbin/lighttpd
为Lighttpd建立用户和用户组:
groupadd lighttpd
adduser -m -g lighttpd -d /var/www -s /sbin/nologin lighttpd
为Lighttpd建立文件夹和设置所有权:
mkdir /var/log/lighttpd
chown lighttpd:lighttpd /var/log/lighttpd
修改配置文件:
vi /etc/lighttpd/lighttpd.conf
启动Lighttpd:
service lighttpd start
设置根目录文件夹:
server.document-root = "/srv/www/htdocs/"
设置用户名和组:
perl -i -p -e 's/#server.username = "wwwrun"/server.username = "lighttpd"/g;' /etc/lighttpd/lighttpd.conf
perl -i -p -e 's/#server.groupname = "wwwrun"/server.groupname = "lighttpd"/g;' /etc/lighttpd/lighttpd.conf
设置pid文件:
server.pid-file = "/var/run/lighttpd.pid"