`
xinghu
  • 浏览: 31559 次
  • 性别: Icon_minigender_1
  • 来自: 北京
最近访客 更多访客>>
文章分类
社区版块
存档分类
最新评论

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 不大管用。研究中……

 

 

 

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics