不喜歡 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.*
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
分享到:
相关推荐
Fedora Core 6 Linux安装配置详细介绍
fedoracore linux6安装图解
红帽子Linux Fedora Core 6安装全程图解.rar 红帽子Linux Fedora Core 6安装全程图解.rar 红帽子Linux Fedora Core 6安装全程图解.rar
Fedora Core 6 安装 部署说明文档
硬盘安装Fedora 的详细过程,是我自己写的,大家凑和看吧~
在VMware上安装Fedora Core 9步骤详解
Fedora Core9的硬盘安装攻略,对想学习linux的同志有所帮助.
在Fedora core linux中安装VMware Workstaton虚拟机.pdf
Fedora Core 5.0 安装图文版Fedora Core 5.0 安装图文版
一、硬盘安装 二、几点感受 三、ADSL上网设置 四、关闭不需要的服务进程 五、让终端的字体更清晰些 六、挂载Win分区 七、寻找可执行文件 八、让“添加/删除软件”不再是摆设 九、让KDE显示中文菜单 十、...
fedora一些安装说明fedora一些安装说明fedora一些安装说明fedora一些安装说明
fedora+7+安装图解 fedora+7+安装图解 fedora+7+安装图解
挺详细的FC6安装教程!
Linux作为在服务器行业使用最多的操作系统,是我们学习网络的人必须学会的。而在虚拟机上安装 linux,不仅安全,而且可以和我们的原来系统建立网络连接。...Fedora Core 6的5张安装盘(建议使用ISO文件)
详细介绍Fedora Core 9 的系统安装全过程,并带有清晰图片分布介绍,令学者一目了然。
Fedora Core 5 新手指南 本指南由Latvia大学Linux中心和热心帮助的人们维护,文章内容遵守 GNU Free Documentation License 1.2. 本文是Fedora Core 5的上手指南,与Fedora项目和Redhat公司没有联系。
Fedora Core 5.0 安装教程,学习必备
Fedora 7图解安装教程 Fedora 7图解安装教程 Fedora 7图解安装教程 Fedora 7图解安装教程