CentOS 5.2 ã« Ruby on Rails ãã¤ã³ã¹ãã¼ã«ãã
$ ã§å§ã¾ãè¡ã¯ä¸è¬ã¦ã¼ã¶ã# ã§å§ã¾ãè¡ã¯ rootã
1. yum 㧠Ruby ã¨é¢é£ã®ããã±ã¼ã¸ãã¤ã³ã¹ãã¼ã«
$ su - # yum install ruby ruby-devel ruby-docs ruby-irb ruby-libs ruby-mode ruby-rdoc ruby-tcltk
2. RubyGems ãã¤ã³ã¹ãã¼ã«
RubyGems (Perl ã® CPAN, PHP ã® PEAR ã«ç¸å½ãããã®) ãã¤ã³ã¹ãã¼ã«ã
- ææ°çã¯ããããâ http://rubyforge.org/frs/?group_id=126
# wget http://rubyforge.org/frs/download.php/57643/rubygems-1.3.4.tgz # tar -xvzf rubygems-1.3.4.tgz # cd rubygems # ruby setup.rb # cd .. # rm rubygems-1.3.4.tgz # rm -rf rubygems-1.3.4
3. Rails ãã¤ã³ã¹ãã¼ã«
# gem install rails
4. Rails ã®ãã£ã¬ã¯ããªãä½ã£ã¦ã¿ã
$ cd $ mkdir rails $ cd rails $ rails myapp $ cd myapp $ tree . |-- README |-- Rakefile |-- app | |-- controllers | | `-- application_controller.rb | |-- helpers | | `-- application_helper.rb | |-- models | `-- views | `-- layouts
ãã£ã¬ã¯ããªã« Rails ã®ãã¡ã¤ã«ç¾¤ãæ§ç¯ããã¦ããã
5. ãµã¼ããèµ·å
$ ruby script/server
Ruby æ¨æºã® Web ãµã¼ã WEBrick ãèµ·åããã®ã§ãWeb ãã©ã¦ã¶ãã http://(ãµã¼ãã®IPã¢ãã¬ã¹):3000/ ã«ã¢ã¯ã»ã¹ãã¦ç¢ºèªã
ãã®ãããªç»é¢ãåºãã OKãã³ã³ã½ã¼ã«ãã Ctrl+C ã§åæ¢ã
6. Web ãµã¼ãã Passenger (é称: mod_rails) ã«å¤æ´
TCP 80çªã§å¼ã³åºããããmod_rails+Apache ã使ããmongrel ã使ãå ´åã¯ã¹ãããã
mod_rails ãã¤ã³ã¹ãã¼ã«
# yum install gcc-c++ ## gcc-c++ããã±ã¼ã¸ãå¿ è¦ # gem install passenger # passenger-install-apache2-module
passenger.conf ãä½æ
passenger-install-apache2-module ãå®è¡ããå¾ã«è¡¨ç¤ºãããé ç®ãã³ããã
# vi /etc/httpd/conf.d/passenger.conf LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4/ext/apache2/mod_passenger.so PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.2.4 PassengerRuby /usr/bin/ruby
ãã¼ãã£ã«ãã¹ãã«è¿½å
# vi /etc/httpd/conf/httpd.conf ## ã³ã¡ã³ãã¢ã¦ããã¦ãã¼ãã£ã«ãã¹ããæå¹ã« NameVirtualHost *:80 ## ä¸è¨ã追å <VirtualHost *:80> DocumentRoot /home/username/rails/myapp/public ServerName rails.domain.com </VirtualHost>
Apacheãåèµ·å
# service httpd restart
ãã©ã¦ã¶ããã¢ã¯ã»ã¹
æå¹ãªã¢ããªããªãå ´åã¯ä¸ã®ãããªã¨ã©ã¼ç»é¢ããRails ã®ãã¼ã ã表示ããããã©ãã¨ããããããã§OKã
7. mod_rails ã§ã¯ãªããmongrel ã使ãå ´åã¯ãã¡ãã
mongrel ãã¤ã³ã¹ãã¼ã«
# gem install mongrel $ cd ~/rails/myapp/ $ mongrel_rails start
Apache ã«è¨å®ãã
ãã¼ãã£ã«ãã¹ãã®ãªãã¼ã¹ãããã·ã¨ãã¦è¨å®ããã
# vi /etc/httpd/conf/httpd.conf ##ã³ã¡ã³ãã¢ã¦ããã¦ãmod_proxy ãèªã¿è¾¼ã LoadModule proxy_module modules/mod_proxy.so ## ã³ã¡ã³ãã¢ã¦ããã¦ãã¼ãã£ã«ãã¹ããæå¹ã« NameVirtualHost *:80 ## ä¸è¨ã追å <VirtualHost *:80> DocumentRoot /var/www/html ServerName rails.domain.com <IfModule mod_proxy.c> ProxyPass / http://localhost:3000/ ProxyPassReverse / http://localhost:3000/ </Ifmodule> </VirtualHost>