Fedora 9 下使用apache+mongrel+rails轻松架设ROR应用

来源:互联网 发布:网易云课堂软件 编辑:程序博客网 时间:2024/05/01 12:14

1. 安装 ruby
  1. [root@www ~]# yum install ruby* -y

2. 更新ruby
  1. [root@www ~]# gem update --system
  2. [root@www ~]# gem update
3.install Rails and dependencies
  1. [root@www~]gem install rails –include-dependencies
4.安装常用的gem包
 
  1. [root@www ~]# gem install ruby-debug ruby-debug-base sqlite3-ruby
  2. Successfully installed ruby-debug-0.10.2
  3. Building native extensions.  This could take a while...
  4. Successfully installed ruby-debug-base-0.10.2
  5. Building native extensions.  This could take a while...
  6. Successfully installed sqlite3-ruby-1.2.4
  7. 3 gems installed
  8. Installing ri documentation for ruby-debug-0.10.2...
  9. Installing ri documentation for ruby-debug-base-0.10.2...
  10. Installing ri documentation for sqlite3-ruby-1.2.4...
  11. Installing RDoc documentation for ruby-debug-0.10.2...
  12. Installing RDoc documentation for ruby-debug-base-0.10.2...
  13. Installing RDoc documentation for sqlite3-ruby-1.2.4...
  14. [root@www ~]# 

5. install Mongrel
方法同4
  1. [root@www ~]# gem install mongrel
6. 若使用mysql, 还可能需要执行以下操作
  1. [root@www ~]# yum install mysql*
  2. [root@www ~]# gem install mysql

7. 安装 & 配置Apache

  1. [root@www~]yum install httpd
新建/etc/httpd/conf.d/rails.conf内容如下
 
  1. Listen 8080
  2. ProxyRequests Off
  3. <Proxy balancer://myCluster>
  4. BalancerMember http://127.0.0.1:3001
  5. BalancerMember http://127.0.0.1:3002
  6. #BalancerMember http://127.0.0.1:3003
  7. #BalancerMember http://127.0.0.1:3004
  8. #BalancerMember http://127.0.0.1:3005
  9. </Proxy>
  10. <VirtualHost *:8080>
  11. ServerName www.laiyunqing.com:8080
  12. DocumentRoot /var/www/beeblio/public
  13. ProxyPass /image !
  14. ProxyPass /stylesheets !
  15. ProxyPass /javascripts !
  16. ProxyPass / balancer://myCluster/
  17. ProxyPassReverse / balancer://myCluster/
  18. ProxyPreserveHost on
  19. </VirtualHost>
然后在3001,3002...3005端口启动mongrel
mongrel_rails start -e production -p 3001 -d -c /var/www/beeblio/ -P /var/www/beeblio/log/mongrel-3001.pid
mongrel_rails start -e production -p 3001 -d -c /var/www/beeblio/ -P /var/www/beeblio/log/mongrel-3002.pid
...
8. 重启apache,试试地址栏中输入http://localhost:8080,该工作了吧?
  1. [root@www~]service httpd restart