CentOS源码编译安装Lighttpd

安装必要的软件

  1. yum -y install glib2-devel openssl-devel pcre-devel bzip2-devel gzip-devel
  2. yum -y install gamin
  3. yum -y install gamin-devel
  4. yum -y install gcc gcc-c++

安装Lighttpd

http://www.lighttpd.net/下载最新版,现在最新版是1.4.28。

  1. cd /usr/local/src
  2. wget http://download.lighttpd.net/lighttpd/releases-1.4.x/lighttpd-1.4.28.tar.gz
  3. tar -zxvf lighttpd-1.4.28.tar.gz
  4. cd lighttpd-1.4.28
  5. make clean && make distclean
  6. ./configure –with-fam
  7. make
  8. make install

配置Lighttpd

  1. sed -e ‘s/FOO/lighttpd/g’ doc/rc.lighttpd.redhat > /etc/init.d/lighttpd
  2. chmod 755 /etc/init.d/lighttpd
  3. echo "LIGHTTPD_CONF_PATH=/etc/lighttpd/lighttpd.conf" > /etc/sysconfig/lighttpd
  4. install -Dp ./doc/lighttpd.conf /etc/lighttpd/lighttpd.conf
  5. chkconfig lighttpd on

创建符号链接

  1. ln -s /usr/local/sbin/lighttpd /usr/sbin/lighttpd

为Lighttpd建立用户和用户组

  1. groupadd lighttpd
  2. adduser -m -g lighttpd -d /var/www -s /sbin/nologin lighttpd

为Lighttpd建立文件夹和设置所有权

  1. mkdir /var/log/lighttpd
  2. chown lighttpd:lighttpd /var/log/lighttpd

修改配置文件

  1. vi /etc/lighttpd/lighttpd.conf

启动Lighttpd

  1. service lighttpd start

设置根目录文件夹

  1. server.document-root        = "/srv/www/htdocs/"

设置用户名和组

  1. perl -i -p -e ‘s/#server.username            = "wwwrun"/server.username            = "lighttpd"/g;’ /etc/lighttpd/lighttpd.conf
  2. perl -i -p -e ‘s/#server.groupname           = "wwwrun"/server.groupname           = "lighttpd"/g;’ /etc/lighttpd/lighttpd.conf

设置pid文件

  1. server.pid-file            = "/var/run/lighttpd.pid"