lighttpd 安装与配置

操作系统: Ubuntu 9.10

 

安装基本上是按照http://www.lighttpd.com.cn/?p=56 介绍的来的,略去了 安装ruby rails mysql部分

 

1.从安装 fcgi开始

 

http://www.fastcgi.com/dist/
tar xzvf fcgi-2.4.0.tar.gz
cd fcgi-2.4.0
./configure --prefix=/usr/local/system/fcgi
make && make install

 

2.安装fcgi的ruby支持库

 

http://rubyforge.org/projects/fcgi/
tar xzvf ruby-fcgi-0.8.7.tar.gz
cd ruby-fcgi-0.8.7
ruby install.rb config -- --with-fcgi-include=/usr/local/system/fcgi/include --with-fcgi-lib=/usr/local/system/fcgi/lib
ruby install.rb setup
ruby install.rb install
 

3.安装lighttpd

 

http://www.lighttpd.net/download/
tar xzvf lighttpd-1.4.13.tar.gz
cd lighttpd-1.4.13
./configure --prefix=/usr/local/system/lighttpd
configure完毕以后,会给出一个激活的模块和没有激活模块的清单,可以检查一下,是否自己需要的模块都已经激活
,在enable的模块中一定要有“mod_rewrite”这一项,否则重新检查pcre是否安装。然后编译安装:
make && make install
注:这一步如果没有安装pcre的会报错。安装完 pcre再安装。
 

   备注:安装pcre

 

   wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-7.8.zip

unzip pcre-7.8.zip
cd pcre-7.8
./configure --enable-utf8 --enable-unicode-properties
make
make install
 

 

4.配置lighttpd

 

mkdir /etc/lighttpd
cp doc/lighttpd.conf /etc/lighttpd/lighttpd.conf

建立启动脚本
vi /etc/init.d/lighttpd
将下面内容写入,保存


#!/bin/sh

export PATH=/bin:/sbin:/usr/bin:/usr/sbin:$PATH

case $1 in

start)
/usr/local/system/lighttpd/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf > /dev/null 2>&1
echo "started!"
;;
stop)
killall lighttpd
echo "lighttpd stopped"
;;
restart)
$0 stop
echo "hah"
$0 start
;;
*)
echo "Usag $0 [start|stop|restart]"
;;
esac

exit 0

 

 

5.修改/etc/lighttpd/lighttpd.conf

 

1. 取消需要用到模块的注释,mod_rewrite,mod_access,mod_fastcgi,mod_simple_vhost,mod_cgi,mod_compress,mod_accesslog是一般需要用到的。

 

 2.server.document-root = "/rails_app/" server.errorlog = "/rails_app/log/lighttpd/error.log" 

  3.compress.cache-dir="/tmp/lighttpd/cache/compress” #自己新建/tmp/lighttpd/cache/compress 文件夹
compress.filetype=(”text/plain”, “text/html”,”text/javascript”,”text/css”)
   

4.配置ruby on rails
最简单的配置如下:
$HTTP["host"] == “www.xxx.com” {
server.document-root = “/yourrails/public”
server.error-handler-404 = “/dispatch.fcgi”
fastcgi.server = (”.fcgi” =>
(”localhost” =>
(”min-procs” => 10,
“max-procs” => 10,
“socket” => “/tmp/lighttpd/socket/rails.socket”, #需要手工建 lighttpd/socket 文件夹
“bin-path” => “/yourrails/public/dispatch.fcgi”,
“bin-environment” => (”RAILS_ENV” => “production”)
)
)
)
}
 

 

 

配置完毕,启动 lighttpd.挂了,发现 居然 rails_app/public下居然没有  dispatch.fcgi,google,发现原来是 rails2.3 之后 不自动生成了,需要用命令生成 

 

rake rails:update:generate_dispatchers

(rails 2.3.5)
 

再次启动,依旧没有启动,报错

 

child exited with status 2

 再次Google,这次问题比较棘手,找了好多没发现解决办法。无意中,一个仁兄的回复说到,可能是系统没有找到fcgi路径,让我想到可能是 环境变量没有配置好。

 

 vi /ect/enviroment

 

 在PATH后面写上 fcgi的路径,source /etc/enviroment.

 

再次启动,大功告成!

 

 

 

稍有遗憾,那个启动脚本,start和stop都好使,可是restart 不大管用。研究中……

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值