Lighttpd是一个德国人领导的开源Web服务器软件,其根本的目的是提供一个专门针对高性能网站,安全、快速、兼容性好并且灵活的web server环境。具有非常低的内存开销、cpu占用率低、效能好以及丰富的模块等特点。
Lighttpd是众多OpenSource轻量级的web server中较为优秀的一个。支持FastCGI,CGI,Auth,输出压缩(output compress),URL重写,Alias等重要功能;而Apache之所以流行,很大程度也是因为功能丰富,在lighttpd上很多功能都有相应的实现了,这点对于apache的用户是非常重要的,因为迁移到lighttpd就必须面对这些问题。
演示环境:CentOS6.5 + lighttpd-1.4.45
本文介绍在CentOS6.5系统上,用源码方式安装lighttpd-1.4.45的详细步骤。
1. 安装编译所需的相关软件包
[root@ecs-33b2var]# yum -y install pcre pcre-devel bzip2-devel zlib zlib-devel mysql-serverphp php-mysql
2. 下载Lighttpd源码包
[root@ecs-33b2var]# cd /usr/local/src
[root@ecs-33b2var]# wget http://download.lighttpd.net/lighttpd/releases-1.4.x/lighttpd-1.4.45.tar.gz
解压到/usr/local目录
[root@ecs-33b2var]# tar -xvf lighttpd-1.4.45.tar.gz -C /usr/local/
3. 配置、编译并安装
[root@ecs-33b2var]# cd /usr/local/
[root@ecs-33b2var]# ./configure --prefix=/usr/local/lighttpd --with-openssl --with-openssl-libs=/usr/lib
[root@ecs-33b2var]# make && make install
4. 配置启动文件及配置文件目录
配置启动文件及开机启动
[root@ecs-33b2var]# cp doc/initscripts/rc.lighttpd.redhat /etc/init.d/lighttpd
[root@ecs-33b2var]# chmod +x /etc/init.d/lighttpd
[root@ecs-33b2var]# cp -p doc/initscripts/sysconfig.lighttpd /etc/sysconfig/lighttpd
[root@ecs-33b2var]# mkdir -p /etc/lighttpd
[root@ecs-33b2var]# cp -rf doc/config/* /etc/lighttpd/
[root@ecs-33b2var]# chkconfig --add lighttpd
[root@ecs-33b2var]# chkconfig lighttpd on
配置启动文件目录
[root@ecs-33b2var]# vim +29 /etc/init.d/lighttpd
lighttpd="/usr/sbin/lighttpd"
修改成:
lighttpd="/usr/local/lighttpd/sbin/lighttpd"
创建用户,配置日志目录
[root@ecs-33b2var]# mkdir -p /srv/www/htdocs
[root@ecs-33b2var]# mkdir /var/log/lighttpd
[root@ecs-33b2var]# touch /var/log/lighttpd/access.log
[root@ecs-33b2var]# touch /var/log/lighttpd/error.log
[root@ecs-33b2var]# useradd -s /sbin/nologin lighttpd
[root@ecs-33b2var]# chown -R lighttpd:lighttpd /var/log/lighttpd/
将压缩缓存目录修改到/tmp下:
vim/etc/lighttpd/lighttpd.conf
var.cache_dir = "/tmp/cache/lighttpd"
5. 启动Lighttpd服务,查看监听端口
[root@ecs-33b2var]# /etc/init.d/lighttpd start
Startinglighttpd: [ OK ]
[root@ecs-33b2var]# netstat -tnlp | grep lighttpd
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 10601/lighttpd
6. 创建测试页面&验证
在/srv/www/htdocs下建立以下测试文件:
[root@ecs-33b2htdocs]# vi index.html
Test page...
在浏览器中打开URL:http://139.159.140.92/
展示如下页面,表示测试页面打开正常。
以上就是CentOS 6.5上通过源码方式安装Lighttpd的步骤了,若有疑问,欢迎添加测试交流群交流。
关注公众号,了解更多测试技术
领取专属 10元无门槛券
私享最新 技术干货