step by step 在Redhat 下部署rforum 为lighttpd + fastcgi

今天尝试了一下部署一个rails 应用到lighttpd + fastcgi的环境, 把步骤记了一下,
希望对其他人也有用.

Lighttpd 部分的配置有点粗糙,主要是图省事所以很多地方的路径都写死了.

我的操作系统是Redhat 4

首先 在sudoers中加入一个可以使用sudo命令的用户.

[color=olive]su[/color]

[color=olive]vi /etc/sudoers[/color]

找到这行
[b]# User privilege specification
root ALL=(ALL) ALL[/b]


然后加入你的用户名

[b]# User privilege specification
root ALL=(ALL) ALL
yourUserName ALL=(ALL) ALL[/b]


保存, 退出.

[color=olive]su yourUserName [/color]


[b]1. 安装Ruby On Rails[/b]

下载ruby源码 http://rubyforge.org/frs/download.php/7858/ruby-1.8.4.tar.gz
复制到/home/yourUserName/rubys
[color=olive]cd /home/yourUserName/rubys
tar zxvf ruby-1.8.4.tar.gz
cd ruby-1.8.4
sudo ./configure
sudo make
sudo make install[/color]

[b]安装gems[/b]
下载gems
[color=olive]cd rubygems-0.8.11
sudo ruby setup.rb[/color]
如果成功能看到 Successfully build Ruby Gems.


[b]安装rails[/b]
[b][color=olive]export http_proxy=http://servername:port[/color][/b]
[color=olive]sudo gem install rails --include-dependencies[/color]

[b]2. 安装 lighttpd 及fastcgi[/b]

[color=olive]tar zvxf lighttpd-1.4.13.tar.gz
cd lighttpd-1.4.13
sudo ./configure
sudo make
sudo make install[/color]

[color=olive][b]接下去安装fastcgi lib[/b]
wget http://www.fastcgi.com/dist/fcgi.tar.gz
tar zxvf fcgi-2.4.0.tar.gz
cd fcgi-2.4.0
sudo ./configure
sudo make
sudo make install[/color]

[b]接下去安装 Ruby FastCGI Bindings[/b]
[color=olive]wget http://sugi.nemui.org/pub/ruby/fcgi/ruby-fcgi-0.8.6.tar.gz
tar zxvf ruby-fcgi-0.8.6.tar.gz
cd ruby-fcgi-0.8.6
sudo ruby install.rb config
sudo ruby install.rb setup
sudo ruby install.rb install[/color]

[b]3. 配置 Lighttpd[/b]

创建几个目录

/home/yourHomeDir/web/etc
/home/yourHomeDir/web/var




[b]创建Lighttpd 配置文件 [/b]
cd /home/yourHomeDir
vi lighttpd.conf

输入以下内容
[code]server.port = 80
server.pid-file = "/home/yourHomeDir/web/etc/lighttpd.pid"

server.modules = ( "mod_redirect", "mod_access", "mod_fastcgi", "mod_accesslog", "mod_simple_vhost" )

server.document-root = "/home/yourHomeDir/web/"
server.indexfiles = ( "index.php", "index.html" )
accesslog.filename = "/home/yourHomeDir/web/var/access_log"
server.errorlog = "/home/yourHomeDir/web/var/error_log"

# simple virtual hosting
simple-vhost.server-root = "/home/yourHomeDir/web"
simple-vhost.default-host = "test"
simple-vhost.document-root = "public"

# Start of test vhost
$HTTP["host"] == "test" {
server.document-root = "/home/yourHomeDir/web/rforum/public/"
accesslog.filename = "/home/yourHomeDir/web/rforum/access.log"
server.indexfiles = ( "dispatch.fcgi", "index.html" )
server.error-handler-404 = "/dispatch.fcgi"

# rails stuff
#### fastcgi module
fastcgi.server = (
".fcgi" => (
"test" => (
"socket" => "/tmp/test1.socket",
"bin-path" => "/home/yourHomeDir/web/rforum/public/dispatch.fcgi",
"min-procs" => 1,
"max_procs" => 2
)
)
)
}
# End of test vhost

# mimetype mapping
mimetype.assign = (
".rpm" => "application/x-rpm",
".pdf" => "application/pdf",
".sig" => "application/pgp-signature",
".spl" => "application/futuresplash",
".class" => "application/octet-stream",
".ps" => "application/postscript",
".torrent" => "application/x-bittorrent",
".dvi" => "application/x-dvi",
".gz" => "application/x-gzip",
".pac" => "application/x-ns-proxy-autoconfig",
".swf" => "application/x-shockwave-flash",
".tar.gz" => "application/x-tgz",
".tgz" => "application/x-tgz",
".tar" => "application/x-tar",
".zip" => "application/zip",
".mp3" => "audio/mpeg",
".m3u" => "audio/x-mpegurl",
".wma" => "audio/x-ms-wma",
".wax" => "audio/x-ms-wax",
".ogg" => "audio/x-wav",
".wav" => "audio/x-wav",
".gif" => "image/gif",
".jpg" => "image/jpeg",
".jpeg" => "image/jpeg",
".png" => "image/png",
".xbm" => "image/x-xbitmap",
".xpm" => "image/x-xpixmap",
".xwd" => "image/x-xwindowdump",
".css" => "text/css",
".html" => "text/html",
".htm" => "text/html",
".js" => "text/javascript",
".asc" => "text/plain",
".c" => "text/plain",
".conf" => "text/plain",
".text" => "text/plain",
".txt" => "text/plain",
".dtd" => "text/xml",
".xml" => "text/xml",
".mpeg" => "video/mpeg",
".mpg" => "video/mpeg",
".mov" => "video/quicktime",
".qt" => "video/quicktime",
".avi" => "video/x-msvideo",
".asf" => "video/x-ms-asf",
".asx" => "video/x-ms-asf",
".wmv" => "video/x-ms-wmv",
".bz2" => "application/x-bzip",
".tbz" => "application/x-bzip-compressed-tar",
".tar.bz2" => "application/x-bzip-compressed-tar"
)[/code]



[b]创建一个启动Lighttpd 脚本 vi lighttpd.sh[/b]
内容如下
[code]
#!/bin/sh
# This is for Starting/Stopping/Restarting Lighttpd. You won't need
# to edit anything.

HOME=/home/yourHomeDir
LIGHTTPD_CONF=$HOME/etc/lighttpd/lighttpd.conf
PIDFILE=$HOME/var/run/lighttpd.pid
export SHELL=/bin/sh

case "$1" in
start)
# Starts the lighttpd deamon
echo "Starting Lighttpd"
PATH=$PATH:/usr/local/bin /usr/local/sbin/lighttpd -f $LIGHTTPD_CONF
;;
stop)
# stops the daemon bt cat'ing the pidfile
echo "Stopping Lighttpd"
kill `/bin/cat $PIDFILE`
;;
restart)
## Stop the service regardless of whether it was
## running or not, start it again.
echo "Restarting Lighttpd"
$0 stop
$0 start
;;
reload)
# reloads the config file by sending HUP
echo "Reloading config"
kill -HUP `/bin/cat $PIDFILE`
;;
*)
echo "Usage: lighttpdctrl (start|stop|restart|reload)"
exit 1
;;
esac[/code]
上面脚本里的yourHomeDir改为你实际的用户目录.

4. 将rforum解压缩到/home/yourHomeDir/web/

接下去根据rforum的readme配置rforum




[b]ok, 运行sudo ./lighttpd.sh start来启动 lighttpd.[/b]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值