作者godfat (godfat 真常)
看板Ruby
标题[心得] Fedora Core 6 上安装 beast (2)
时间Wed Aug 15 21:24:58 2007
要 copy 片段的话这里看比较方便:
http://lightyror.thegiive.net/2007/08/fedora-core-6-beast-2.html
或
http://blog.godfat.idv.tw/2007/08/fedora-core-6-beast-2.html
或
....真糟糕,我灌 beast 那台 server 现在没反应 XD
Fedora Core 6 上安装 beast (2)
不喜欢 apache 吗?apache 没办法用 mod_proxy_balancer 吗?
没关系,我找到另外一个不错的方式了,是 pound + lighttpd.
如果不想用 apache 的话,上一篇的 httpd 相关的东西都不要灌,
改灌:
sudo yum install Pound
sudo yum install lighttpd
我是觉得这边分大小写很没意义,不过 yum 就是这样﹍。
pound 是什麽?
The Pound program is a reverse proxy, load balancer and HTTPS front-end for
Web server(s). Pound was developed to enable distributing the load among
several Web-servers and to allow for a convenient SSL wrapper for those
Web servers that do not offer it natively.
lighttpd 我想大家都知道,一个非常快速的 http server, 只不过他的
mod_proxy 似乎有很多问题,以致於没办法用他。所以这部份用 pound 当
前端解决这个问题,流程变成:
http request => pound => lighttpd or mongrel cluster
安装好後,先来设定 pound, 不过 https 就先暂时略过不管。
sudo nano /etc/pound.cfg
=========================
User "pound"
Group "pound"
ListenHTTP
Address 0.0.0.0
Port 80
End
Service
URL "/(images|stylesheets|javascripts)/"
BackEnd
Address 127.0.0.1
Port 1999
End
Session
Type BASIC
TTL 300
End
End
Service
BackEnd
Address 127.0.0.1
Port 2000
End
BackEnd
Address 127.0.0.1
Port 2001
End
BackEnd
Address 127.0.0.1
Port 2002
End
Session
Type BASIC
TTL 300
End
End
=========================
前面的设定是把 host/images, host/stylesheets, host/javascripts
这三个 url 下的 request 都丢给 port 1999 处理,也就是等会 lighttpd
要使用的 port. 这边使用 regex, 可以自由设定自己要的规则。假使未来 user
要使用 file_column, 可以再加个 user/avatar 之类的。
下面的则是全部丢给 mongrel_cluster 处理。设定上应该比 apache 简单地多。
可以先测试看看,先把 lighttpd 的部份 comment 起来,启动 pound 试试:
sudo pound
照理说这样就能使用了。不行的话加个 config 档路径给他:
sudo pound -f /etc/pound.cfg
这边我是在想要不要把 config 也放到 beast 里面,不过 pound 应该只会
有一个,所以我想还是放到 /etc 下好了。停止 pound 的方式:
sudo kill `sudo cat /var/run/pound.pid`
制作 lighttpd 设定档:
nano config/lighttpd.conf
==========================
server.modules = (
"mod_access",
"mod_accesslog"
)
server.port = 1999
server.bind = "127.0.0.1"
server.document-root = "/home/YOUR_NAME/projects/beast/stable-1.0/public"
server.username = "YOUR_NAME"
server.groupname = "YOUR_NAME"
server.pid-file = "/home/YOUR_NAME/projects/beast/stable-1.0/tmp/pids/\
lighttpd.pid"
server.errorlog = "/home/YOUR_NAME/projects/beast/stable-1.0/log/\
lighttpd_error.log"
index-file.names = ( "index.html", "default.html" )
accesslog.filename = "/home/YOUR_NAME/projects/beast/stable-1.0/log/\
lighttpd_access.log"
# 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" => "application/ogg",
".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",
".cpp" => "text/plain",
".log" => "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"
)
==========================
我很想省略 mime-type 设定,不过不设的话 firefox 好像会有问题。
safari 和 opera 是 ok 的,IE 我没得测就没测了。反正要设就是了,
有没有问题不影响。只是希望 lighttpd 能内建这些设定﹍。
启动 lighttpd
sudo lighttpd -f config/lighttpd.conf
这样就算大功告成了!刚刚有测试 pound 的话记得改回原本设定并重新启动。
比较详细的介绍与说明可以参考这篇:
Configuring pound with lighttpd and mongrel.
http://www.aidanf.net/rails/configuring-pound-with-lighttpd-and-mongrel
*
summary:
用到的 server:
(1)
apache2.2 =>
reverse proxy + load balancer + serve static files
(2)
pound => reverse proxy + load balancer
lighttpd => serve static files
(3)
mongrel_cluster => setup mongrel cluster
mongrel => serve beast
结果就是 ((1) or (2)) + (3)
操作 apache:
启动:sudo apachectl start
停止:sudo apachectl stop
重启:sudo apachectl restart
操作 pound:
启动:sudo pound -f /etc/pound.cfg
或:sudo /etc/init.d/pound start
停止:sudo kill `sudo cat /var/run/pound.pid`
或:sudo /etc/init.d/pound stop
重启:sudo /etc/init.d/pound restart
操作 lighttpd:
启动:sudo lighttpd -f config/lighttpd.conf
或:sudo /etc/init.d/lighttpd start
停止:sudo kill `cat tmp/pids/lighttpd.pid`
或:sudo /etc/init.d/lighttpd stop
重启:sudo /etc/init.d/lighttpd restart
操作 mongrel_cluster:
启动:sudo mongrel_rails cluster::start
停止:sudo mongrel_rails cluster::stop
重启:sudo mongrel_rails cluster::restart
操作 postgresql:
启动:sudo pg_ctl start
停止:sudo pg_ctl stop
重启:sudo pg_ctl restart
作者: godfat 真常 在 8/15/2007 02:02:00 下午
--
生死去来、棚头傀儡、一线断时、落落磊磊
《花镜》-世阿弥
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 220.135.28.18