Chinaunix首页 | 论坛 | 博客
  • 博客访问: 292327
  • 博文数量: 52
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 587
  • 用 户 组: 普通用户
  • 注册时间: 2017-03-09 09:24
个人简介

水滴

文章分类

全部博文(52)

文章存档

2021年(3)

2019年(8)

2018年(32)

2017年(9)

我的朋友

分类: LINUX

2018-05-08 13:40:52

1 应用背景及介绍    

   
  Lighttpd是一个具有非常低的内存开销,cpu占用率低,效能好,以及丰富的模块等特点。lighttpd是众多OpenSource轻量级的web server中较为优秀的一个。支持FastCGI, CGI, Auth, 输出压缩(output compress), URL重写, Alias等重要功能。    

 Lighttpd使用fastcgi方式运行php,它会使用很少的PHP进程响应很大的并发量。

Fastcgi的优点在于:

 从稳定性上看, fastcgi是以独立的进程池运行来cgi,单独一个进程死掉,系统可以很轻易的丢弃,然后重新分配新的进程来运行逻辑.

 从安全性上看, fastcgi和宿主的server完全独立, fastcgi怎么down也不会把server搞垮,

 从性能上看, fastcgi把动态逻辑的处理从server中分离出来, 大负荷的IO处理还是留给宿主server, 这样宿主server可以一心一意作IO,对于一个普通的动态网页来说, 逻辑处理可能只有一小部分, 大量的图片等静态IO处理完全不需要逻辑程序的参与(注1)

 从扩展性上讲, fastcgi是一个中立的技术标准, 完全可以支持任何语言写的处理程序(php,java,python...)。
  因此,在许多嵌入式设备上采用了lighttpd作为web服务器,针对本人工作方向,选择以lighttpd作为web服务器框架,搭建web-server。

2. Lighttpd下载

 

3. lighttpd模块


Optional libraries provide additional feature capabilities to the modules.


feature
required libs
'''what?'''

auth-crypt
crypt() from libc/libcrypt
provides htpasswd and htdigest for basic/digest auth

auth-ldap
libopenldap
auth users against an ldap server

compress-bzip2
libbz2
optional, non-standard bzip2 compress for mod_compress

compress-deflate
libz
deflate compress for mod_compress

compress-gzip
libz
gzip compress for mod_compress

large-files
libc/os
large files support

network-ipv6
libc/os
ipv6 support

network-openssl
libopenssl
ssl cabability

regex-conditionals
libpcre
=~ and !~ in config conditionals

stat-cache-fam
libfam/gamin
caches stat() calls with the help of FAM

storage-gdbm
libgdbm
local, non-cluster storage for mod_trigger_b4_dl

storage-memcache
libmemcached
distributed storage for mod_trigger_b4_dl

webdav-locks
libxml2, sqlite3, libuuid
file locking for mod_webdav

webdav-properties
libxml2, sqlite3
property storage for mod_webdav



4. 简单Makefile编译

通过makefile之间编译,并将其安装到指定目录

LIGHTTPD = ./lighttpd-1.4.49
GCC = gcc
INSTALLDIR = /home/cdl/workspace/install
all:WebServer

WebServer:
        (cd $(LIGHTTPD);./autogen.sh;./configure CC=$(GCC) --prefix $(INSTALLDIR); make; make install)

clean:
        (cd $(LIGHTTPD);make uninstall;make clean)


5.lighttpd配置

可参考文件/lighttpd-1.4.49/tests/lighttpd.conf

简单测试

server.document-root = "/home/cdl/workspace/var/www/pages/"
server.port = 4500
mimetype.assign = (
    ".html" => "text/html",  
    ".txt" => "text/plain",  
    ".jpg" => "image/jpeg",
    ".png" => "image/png")
static-file.exclude-extensions=(".fcgi", ".php", ".rb", "~", ".inc")
index-file.names =( "index.html" )

6. 简单测试HTML

多一个尖括号要去掉哦!

《html》
《body》
《h1》Hello Word《/h1》
《p》     This is test !《/p》
《/body》
《/html》


7. 执行

 sudo ./lighttpd -D -f lighttpd.conf

环境搭建完成。

阅读(11527) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~