CentOS编译安装Lighttpd1.4.28

来源:互联网 发布:知我无情有情 张南雁 编辑:程序博客网 时间:2024/06/03 22:51

CentOS编译安装Lighttpd1.4.28

安装所需编译模块

1
yum installgcc glib2-devel openssl-devel pcre-devel bzip2-develgzip-devel zlib-devel

You need to install following libraries to compile required modules and features:

  • glib2-devel : Gnome header files for version 2 of the GLib library
  • openssl-devel – Used by core and SSL support
  • pcre-devel – Used by mod_redirect, mod_rewrite,
  • bzip2-devel – Use by compress-bzip2
  • zlib-devel – Used by compress-gzip and compress-deflate. It contains the header files and libraries.

下载

1
wget http://download.lighttpd.net/lighttpd/releases-1.4.x/lighttpd-1.4.28.tar.gz

解压

1
tar zxvf lighttpd-1.4.28.tar.gz

进入安装目录

1
cd lighttpd-1.4.28

配置

1
./configure--prefix=/usr/local/lighttpd

编译与安装

1
make && make install

拷贝启动脚本

1
sed -e 's/FOO/lighttpd/g' doc/initscripts/rc.lighttpd >/etc/init.d/lighttpd

修改启动脚本中的lighttpd的安装位置

1
2
vi /etc/init.d/lighttpd
lighttpd="/usr/sbin/lighttpd"-> ighttpd="/usr/local/lighttpd/sbin/lighttpd"

增加脚本的执行权限

1
chmod a+rx /etc/init.d/lighttpd

创建默认配置文件

1
cp -p doc/initscripts/sysconfig.lighttpd/etc/sysconfig/lighttpd

拷贝配置文件

1
2
mkdir -p /etc/lighttpd
cp -R doc/config/conf.d/ doc/config/*.conf doc/config/vhosts.d//etc/lighttpd/

添加到开机自动启动服务

1
chkconfig lighttpd on

修改配置文件

1
vi /etc/lighttpd/lighttpd.conf
var.server_root = "/srv/www" => var.server_root = "/home/wwwroot"
server.use-ipv6 = "enable" => server.use-ipv6 = "disable"
server.username = "lighttpd" => server.username = "www"
server.groupname = "lighttpd" => server.groupname = "www"

运行前的准备

1
2
3
4
5
6
7
8
9
10
11
12
13
# 增加www组与用户
groupadd www
useradd -g www -s /sbin/nologin -d /dev/nullwww
# 分配权限
chown -R www:www /usr/local/lighttpd
chown root:root /etc/rc.d/init.d/lighttpd
chmod 755/etc/rc.d/init.d/lighttpd
# 创建日志目录
mkdir -p /var/log/lighttpd
chown -R www:www /var/log/lighttpd
# 创建网站根目录
mkdir -p /home/wwwroot
chown -R www:www /home/wwwroot