Web服务器 之 lighttpd 轻量级WEB服务器

作者:tonyvicky
来自:LinuxSir.Org
摘要:lighttpd是一个轻量级的WEB服务器软件,支持CGI FASTCGI等
本文重点介绍lighttpd的CGI和FASTCGI模块的使用;

目录
一、关于测试环境
二、下载相关软件
三、安装和配置
1、安装lighttpd
2、配置lighttpd
3、设置CGI
4、设置FASTCGI
5、压力测试
四、关于本文

+-------------------------------------------+
| 正文 |
+-------------------------------------------+

一、关于测试环境

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
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
一个运行于 安卓系统的 小型web服务器,包括php/mysql 配置文件可以修改,另外可以用phpmyadmin 管理数据库。 让你的手机立刻变身小型服务器。 =============================== Turn your Android devices into a web and database server with Palapa Web Server, a suite of web developer. This application has been designed for low memory consumption and CPU usage, specially used for smartphone and tablet. Hey, it's free and you don't need a root access to run Palapa Web Server! # Requirements - Internal memory should not be less than 50MB! - ARM based processor - Minimum Android 2.2 Froyo # Features - Lighttpd 1.4.32 - PHP 5.5.1 - MySQL 5.1.69 - Msmtp 1.4.31 - phpMyAdmin 4.0.4.1 - Web Admin 1.0.1 # Default Document Root - Path : /sdcard/pws/www/ # Default URL - Address : http://127.0.0.1:8080/ # Web Admin Informations - Address : http://127.0.0.1:9999 - Username : admin - Password : admin # MySQL Informations - Host : localhost (127.0.0.1) - Port : 3306 - Username : root - Password : adminadmin # phpMyAdmin Informations - Address : http://127.0.0.1:9999/phpmyadmin - Username : root - Password : adminadmin # Problem? If something is not working properly, please try to restart your phone. # Known Issues As you know, compatibility issue is a big problem of Android phone, I can't test it in all phones. So if it can't work for your phone, just uninstall it, I'm sorry to waste your time. You also can send a mail to let me know your phone model, if I solve it, I will let you know.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值