您的位置:首页 > 运维架构 > Apache

配置apache +mongrel单实例

2007-11-22 17:28 134 查看
背景:
OS: CentOS release 3.6 (Final)
Apache: Apache/2.0.46

开始配置Apache+mongrel+rails


安装ruby


wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.6-p110.tar.gz

tar xzvf ruby-1.8.6-p110.tar.gz


cd ruby-1.8.6-p110


./configure --prefix=/usr/local/ruby


make && make install




在/etc/proifle中加入


export PATH=/usr/local/ruby/bin:$PATH


2)安装gem


wget http://rubyforge.org/frs/download.php/17190/rubygems-0.9.2.tgz

tar xzvf rubygems-0.9.2.tgz


cd rubygems-0.9.2


ruby setup.rb




3)安装rails


gem install rails --include-dependencies


4)安装mongrel


gem install mongrel --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_rails start -e production -p 8080 -r public -l log/m.log -P tmp/pids/dispatch.0.pid -d


6)配置 apache
通过命令:httpd -version
发现:Apache/2.0.46
Apache已安装,于是开始略过安装过程直接配置:


vi /etc/httpd/conf/httpd.conf

文件最后加入:


<VirtualHost *:80>


ServerName space.mofile.com








ErrorLog logs/space.mo.com-error_log


CustomLog logs/space.mo.com-access_log common





ProxyPass / http://127.0.0.1:8080/

ProxyPassReverse / http://127.0.0.1:8080

ProxyPreserveHost on


</VirtualHost>




注意:
1)上面对于apache得配置很粗糙,把所有的请求到推倒了mongrel实例,产品环境中显然是不行的,apache作为反向代理,最好是指把动态请求推给mongrel实例。
2) 仅有单个mongrel实例使得请求变成了单进程,并发性能不太好

对于小流量的网站无所谓,一旦压力增大,恐怕就的考虑Apache+Mongrel_cluster
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: