快捷搜索:   服务器  安全  linux 安全  MYSQL  dedecms

lighttpd 轻量级WEB服务器

  摘要:lighttpd是一个轻量级的WEB服务器软件,支持CGI FASTCGI等

  本文重点介绍lighttpd的CGI和FASTCGI模块的使用;

  一、关于测试环境

  Ubuntu 5.10 , gcc4.0.2 , php5.1.1 , lighttpd 1.4.10

  如果要测试FASTCGI在编译PHP时需要打开fastcgi的选项( --enable-fastcgi)

  二、下载相关软件

  lighttpd http://www.lighttpd.net/download/

  php http://www.php.net

  三、安装和配置

  1、安装lighttpd

  root@tonyvicky:# tar vxzf lighttpd-1.4.10.tar.gz
root@tonyvicky:# cd lighttpd-1.4.10
root@tonyvicky:# ./configure --prefix=/usr/local/lighttpd
root@tonyvicky:# make
root@tonyvicky:# make install
root@tonyvicky:# mkdir /usr/local/lighttpd/htdocs
root@tonyvicky:# mkdir /usr/local/lighttpd/etc
root@tonyvicky:# cp ./doc/lighttpd.conf /usr/local/lighttpd/etc/
    

  2、配置lighttpd

  然后修改配置文件 /usr/local/lighttpd/etc/lighttpd.conf

  把"mod_fastcgi"前边的#去掉(在24行);把"mod_cgi"前边的#去掉(在29行)

  设置网站根目录 server.document-root = "/usr/local/lighttpd/htdocs/" (40行)

  设置错误日志文件路径 server.errorlog = "/usr/local/lighttpd/lighttpd.error.log" (43行)

  设置访问日志文件路径 accesslog.filename = "/usr/local/lighttpd/access.log" (116行)

  启动服务器

  root@tonyvicky:# cd /usr/local/lighttpd/sbin/
root@tonyvicky:# ./lighttpd -f ../etc/lighttpd.conf
    

  如果出现错误请把配置文件中如下内容删除

  $HTTP["url"] =~ "\.pdf$" {
server.range-requests = "disable"
}
    

  3、配置CGI

  修改配置文件

  查找"#### CGI module"在这行之后添加

  cgi.assign = ( ".sh" => "" )
    

  然后我们再写一个shell脚本来作测试 test.sh

  #!/bin/bash
echo "Content-Type: text/html";
echo "";
echo "test";
    

  把这个文件保存到/usr/local/lighttpd/htdocs/下

  并改变权限

  root@tonyvicky:# chmod a+x test.sh
    

  然后用浏览器访问一下 http://localhost/test.sh

  如果能出现"test"的字样,就说明CGI模块正常使用了

  4、配置fastcgi

  修改配置文件

  查找"#### fastcgi module"在这行之后添加

  fastcgi.server = ( ".php" =>
(( "socket" => "/tmp/php.socket",
"bin-path" => "/usr/local/php/bin/php",
"min-procs" => 1,
"max-procs" => 32,
"max-load-per-proc" => 4,
"idle-timeout" => 20
))
)
    

  写一个PHP文件,看看能不能解析出来

  <?
// test.php
phpinfo();
?>
    

  用浏览器访问一下 http://localhost/test.php

  5、压力测试

  四、关于本文

顶(0)
踩(0)

您可能还会对下面的文章感兴趣:

最新评论