歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Fedora 9 下使用apache+mongrel+rails輕松架設ROR應用

Fedora 9 下使用apache+mongrel+rails輕松架設ROR應用

日期:2017/2/28 16:55:12   编辑:Linux教程

環境:Fedora 9

1. 安裝 ruby

[root@www ~]# yum install ruby* -y

2. 更新ruby

[root@www ~]# gem update --system
[root@www ~]# gem update

3.install Rails and dependencies

[root@www~]gem install rails –include-dependencies

4.安裝常用的gem包

[root@www ~]# gem install ruby-debug ruby-debug-base sqlite3-ruby
Successfully installed ruby-debug-0.10.2
Building native extensions. This could take a while...
Successfully installed ruby-debug-base-0.10.2
Building native extensions. This could take a while...
Successfully installed sqlite3-ruby-1.2.4

3 gems installed

Installing ri documentation for ruby-debug-0.10.2...
Installing ri documentation for ruby-debug-base-0.10.2...
Installing ri documentation for sqlite3-ruby-1.2.4...
Installing RDoc documentation for ruby-debug-0.10.2...
Installing RDoc documentation for ruby-debug-base-0.10.2...
Installing RDoc documentation for sqlite3-ruby-1.2.4...
[root@www ~]#

5. install Mongrel
方法同4

[root@www ~]# gem install mongrel

6. 若使用mysql, 還可能需要執行以下操作

[root@www ~]# yum install mysql*
[root@www ~]# gem install mysql

7. 安裝 & 配置Apache

[root@www~]yum install httpd

新建/etc/httpd/conf.d/rails.conf內容如下

Listen 8080

ProxyRequests Off

BalancerMember http://127.0.0.1:3001
BalancerMember http://127.0.0.1:3002
#BalancerMember http://127.0.0.1:3003
#BalancerMember http://127.0.0.1:3004
#BalancerMember http://127.0.0.1:3005

ServerName www.laiyunqing.com:8080
DocumentRoot /var/www/beeblio/public
ProxyPass /image !
ProxyPass /stylesheets !
ProxyPass /javascripts !
ProxyPass / balancer://myCluster/
ProxyPassReverse / balancer://myCluster/
ProxyPreserveHost on


然後在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,該工作了吧?

[root@www~]service httpd restart

Copyright © Linux教程網 All Rights Reserved