安裝必要的軟件
- 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"