教学之友,学习之友。

站长教学网

用Lighttpd做图片服务器

时间:2012-07-30 23:15来源:未知 作者:ken 点击:

因为Lighttpd的具有非常低的内存开销,cpu占用率低,所以很适合用来支持图片服务器。

Lighttpd(发音为lighty)是一套开放源代码的网页服务器,以BSD许可证释出。相较于其他的网页服务器,lighttpd仅需少量的内存及CPU资源即可达到同样的效能。

Lighttpd是一个德国人领导的开源软件,其根本的目的是提供一个专门针对高性能网站,安全、快速、兼容性好并且灵活的web server环境。具有非常低的内存开销,cpu占用率低,效能好,以及丰富的模块等特点。lighttpd是众多OpenSource轻量级的web server中较为优秀的一个。支持FastCGI, CGI, Auth, 输出压缩(output compress), URL重写, Alias等重要功能,而Apache之所以流行,很大程度也是因为功能丰富,在lighttpd上很多功能都有相应的实现了,这点对于apache的用户是非常重要的,因为迁移到lighttpd就必须面对这些问题。站长教学网 eduyo.com

一.安装lighttpd所需的库文件
1.安装 pcre
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.10.tar.gz

tar -zxvf pcre-8.10.tar.gz
cd pcre-8.10
./configure
make
make install2.安装zlib
wget http://zlib.net/zlib-1.2.5.tar.gz

tar -zxvf zlib-1.2.5.tar.gz
cd zlib-1.2.5
./configure
make
make install3.安装bzip2
wget http://www.bzip.org/1.0.5/bzip2-1.0.5.tar.gz

cd bzip2-1.0.5
make
make install

二.安装lighttpd
1.下载lighttpd
wget http://download.lighttpd.net/lighttpd/releases-1.4.x/lighttpd-1.4.28.tar.gz
2.编译安装

tar -zxvf lighttpd-1.4.28.tar.gz
cd lighttpd-1.4.28
groupadd lighttpd
useradd –g lighttpd lighttpd
./configure --prefix=/usr/local/lighttpd
make
make install注意事项
如果make时出现类似以下错误

/usr/local/lib/libbz2.a: could not read symbols: Bad value则需要重新安装bzip2,修改bzip2的Makefile文件
vim Makefile

CFLAGS=-Wall -Winline -O2 -g $(BIGFILES)   #找到此行添加-fPIC,如下:
CFLAGS=-Wall -Winline -O2 -g $(BIGFILES) -fPIC然后重新编译bzip和lighttpd
3.更改配置文件

cp -r doc/config  /usr/local/lighttpd/
mkdir -p /var/log/lighttpd
chown -R lighttpd.lighttpd /var/log/lighttpd
mkdir –p /usr/www/htdocs
chown –R lighttpd.lighttpd /usr/www/htdocs4.配置文件内容:
vim/usr/local/lighttpd/config/lighttpd.conf

var.log_root    = "/var/log/lighttpd"
var.server_root = "/usr/www"
var.state_dir   = "/var/run"
var.home_dir    = "/usr/local/lighttpd/sbin/lighttpd"
var.conf_dir    = "/usr/local/lighttpd/config"
 
var.vhosts_dir  = server_root + "/vhosts"
var.cache_dir   = "/var/cache/lighttpd"
var.socket_dir  = home_dir + "/sockets"
 
include "modules.conf"
server.port = 80
 
server.username  = "lighttpd"
server.groupname = "lighttpd"
 
server.document-root = server_root + "/htdocs"
server.pid-file = state_dir + "/lighttpd.pid"
server.errorlog             = log_root + "/error.log"
 
include "conf.d/access_log.conf"
include "conf.d/debug.conf"
 
server.event-handler = "linux-sysepoll"
server.network-backend = "linux-sendfile"
server.max-fds = 2048
server.stat-cache-engine = "simple"
server.max-connections = 1024
 
index-file.names += (
 "index.xhtml", "index.html", "index.htm", "default.htm", "index.php"
)
 
url.access-deny             = ( "~", ".inc" )
 
$HTTP["url"] =~ "\.pdf$" {
 server.range-requests = "disable"
}
 
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi", ".scgi" )
 
include "conf.d/mime.conf"
include "conf.d/dirlisting.conf"
server.follow-symlink = "enable"
server.upload-dirs = ( "/var/tmp" )图片存放在/usr/www/htdocs下面,生成的图片是以/年/月/日的形式存放的

三.启动lighttpd

/usr/local/lighttpd/sbin/lighttpd -f /usr/local/lighttpd/config/lighttpd

(责任编辑:ken)
TAG标签: Lighttpd
顶一下
(2)
100%
踩一下
(0)
0%
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
注册登录:不允许匿名留言,登录后留言无需输入验证码。
栏目列表
最新内容