配置apache +mongrel单实例
背景:OS: CentOS release 3.6 (Final)
Apache: Apache/2.0.46
开始配置Apache+mongrel+rails
[*]安装ruby
wgetftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.6-p110.tar.gz
tarxzvfruby-1.8.6-p110.tar.gz
cdruby-1.8.6-p110
./configure--prefix=/usr/local/ruby
make&&makeinstall
在/etc/proifle中加入
exportPATH=/usr/local/ruby/bin:$PATH
2)安装gem
wgethttp://rubyforge.org/frs/download.php/17190/rubygems-0.9.2.tgz
tarxzvfrubygems-0.9.2.tgz
cdrubygems-0.9.2
rubysetup.rb
3)安装rails
geminstallrails--include-dependencies
4)安装mongrel
geminstallmongrel--include-dependencies
Select which gem to install for your platform (i686-linux)
1. mongrel 1.0.1 (mswin32)
2. mongrel 1.0.1 (ruby)
3. mongrel 1.0 (mswin32)
4. mongrel 1.0 (ruby)
5. Skip this gem
6. Cancel installation
>2
Select which gem to install for your platform (i686-linux)
1. fastthread 1.0 (ruby)
2. fastthread 1.0 (mswin32)
3. fastthread 0.6.4.1 (mswin32)
4. fastthread 0.6.4.1 (ruby)
5. Skip this gem
6. Cancel installation
>1
5)启动mongrel
cd${your_rails_app_root}
mongrel_railsstart-eproduction-p8080-rpublic-llog/m.log-Ptmp/pids/dispatch.0.pid-d
6)配置 apache
通过命令:httpd -version
发现:Apache/2.0.46
Apache已安装,于是开始略过安装过程直接配置:
vi/etc/httpd/conf/httpd.conf
文件最后加入:
<VirtualHost*:80>
ServerNamespace.mofile.com
ErrorLoglogs/space.mo.com-error_log
CustomLoglogs/space.mo.com-access_logcommon
ProxyPass/http://127.0.0.1:8080/
ProxyPassReverse/http://127.0.0.1:8080
ProxyPreserveHoston
</VirtualHost>
注意:
1)上面对于apache得配置很粗糙,把所有的请求到推倒了mongrel实例,产品环境中显然是不行的,apache作为反向代理,最好是指把动态请求推给mongrel实例。
2) 仅有单个mongrel实例使得请求变成了单进程,并发性能不太好
对于小流量的网站无所谓,一旦压力增大,恐怕就的考虑Apache+Mongrel_cluster
页:
[1]