今天尝试了一下部署一个rails 应用到lighttpd + fastcgi的环境, 把步骤记了一下,
希望对其他人也有用.
Lighttpd 部分的配置有点粗糙,主要是图省事所以很多地方的路径都写死了.
我的操作系统是Redhat 4
首先 在sudoers中加入一个可以使用sudo命令的用户.
su
vi /etc/sudoers
找到这行
# User privilege specification
root ALL=(ALL) ALL
然后加入你的用户名
# User privilege specification
root ALL=(ALL) ALL
yourUserName ALL=(ALL) ALL
保存, 退出.
su yourUserName
1. 安装Ruby On Rails
下载ruby源码 http://rubyforge.org/frs/download.php/7858/ruby-1.8.4.tar.gz
复制到/home/yourUserName/rubys
cd /home/yourUserName/rubys
tar zxvf ruby-1.8.4.tar.gz
cd ruby-1.8.4
sudo ./configure
sudo make
sudo make install
安装gems
下载gems
cd rubygems-0.8.11
sudo ruby setup.rb
如果成功能看到 Successfully build Ruby Gems.
安装rails
export http_proxy=http://servername:port
sudo gem install rails --include-dependencies
2. 安装 lighttpd 及fastcgi
tar zvxf lighttpd-1.4.13.tar.gz
cd lighttpd-1.4.13
sudo ./configure
sudo make
sudo make install
接下去安装fastcgi lib
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
接下去安装 Ruby FastCGI Bindings
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
3. 配置 Lighttpd
创建几个目录
/home/yourHomeDir/web/etc
/home/yourHomeDir/web/var
创建Lighttpd 配置文件
cd /home/yourHomeDir
vi lighttpd.conf
输入以下内容
创建一个启动Lighttpd 脚本 vi lighttpd.sh
内容如下
上面脚本里的yourHomeDir改为你实际的用户目录.
4. 将rforum解压缩到/home/yourHomeDir/web/
接下去根据rforum的readme配置rforum
ok, 运行sudo ./lighttpd.sh start来启动 lighttpd.
希望对其他人也有用.
Lighttpd 部分的配置有点粗糙,主要是图省事所以很多地方的路径都写死了.
我的操作系统是Redhat 4
首先 在sudoers中加入一个可以使用sudo命令的用户.
su
vi /etc/sudoers
找到这行
# User privilege specification
root ALL=(ALL) ALL
然后加入你的用户名
# User privilege specification
root ALL=(ALL) ALL
yourUserName ALL=(ALL) ALL
保存, 退出.
su yourUserName
1. 安装Ruby On Rails
下载ruby源码 http://rubyforge.org/frs/download.php/7858/ruby-1.8.4.tar.gz
复制到/home/yourUserName/rubys
cd /home/yourUserName/rubys
tar zxvf ruby-1.8.4.tar.gz
cd ruby-1.8.4
sudo ./configure
sudo make
sudo make install
安装gems
下载gems
cd rubygems-0.8.11
sudo ruby setup.rb
如果成功能看到 Successfully build Ruby Gems.
安装rails
export http_proxy=http://servername:port
sudo gem install rails --include-dependencies
2. 安装 lighttpd 及fastcgi
tar zvxf lighttpd-1.4.13.tar.gz
cd lighttpd-1.4.13
sudo ./configure
sudo make
sudo make install
接下去安装fastcgi lib
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
接下去安装 Ruby FastCGI Bindings
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
3. 配置 Lighttpd
创建几个目录
/home/yourHomeDir/web/etc
/home/yourHomeDir/web/var
创建Lighttpd 配置文件
cd /home/yourHomeDir
vi lighttpd.conf
输入以下内容
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"
)
创建一个启动Lighttpd 脚本 vi lighttpd.sh
内容如下
#!/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
上面脚本里的yourHomeDir改为你实际的用户目录.
4. 将rforum解压缩到/home/yourHomeDir/web/
接下去根据rforum的readme配置rforum
ok, 运行sudo ./lighttpd.sh start来启动 lighttpd.
- 浏览: 18208 次

- 详细资料
搜索本博客
最近加入圈子
最新评论
-
转: Comparing Programmin ...
有意思
-- by allenjiang -
Oracle 向 Redhat 宣战
寻找能力欠缺,呵呵.
-- by dogstar -
Oracle 向 Redhat 宣战
为啥同时放到论坛后, 我却找不到这个帖子.
-- by Gene -
小瘪三
是啊, 估计老板太过软弱
-- by Gene -
小瘪三
这种人怎么不被开除呢?
-- by ouspec






评论排行榜