Ruby Asylum: Ruby, Ruby Gems, Rails and FastCGI Installation A place for those crazy about Ruby tag:rubyasylum.com,2005:Typo Typo 2006-06-04T12:35:14-07:00 Miraenda urn:uuid:30edc538-5117-4a2b-b7d4-5919a4ed0a13 2006-06-03T21:34:00-07:00 2006-06-04T12:35:14-07:00 Ruby, Ruby Gems, Rails and FastCGI Installation <p>A. Install Ruby (latest source package - <a href="http://ruby-lang.org/en/20020102.html">http://ruby-lang.org/en/20020102.html</a>):<br /> <code>mkdir /root/setup<br /> cd /root/setup && wget ftp.ruby-lang.org/pub/ruby/ruby-1.8.4.tar.gz<br /> tar -xvzf ruby-*<br /> cd ruby-*<br /> ./configure && make && make install<br /></p> <p>B. Install Ruby Gems (latest version - <a href="http://rubyforge.org/frs/?group_id=126">http://rubyforge.org/frs/?group_id=126</a>):<br /> <code>cd /root/setup && wget rubyforge.org/frs/download.php/5207/rubygems-0.8.11.tgz<br /> tar -xvzf rubygems-*<br /> cd rubygems-*<br /> ruby setup.rb</code></p> <p>C. Install Rails:<br /> <code>gem install rails</code> <p>(Answer <strong>y</strong> to all the dependancies)</p> <p>D. Install FCGI and FastCGI (sourced from <a href="http://fastcgi.com/dist/">http://fastcgi.com/dist/</a>):<br /> <code>cd /root/setup && wget fastcgi.com/dist/fcgi-2.4.0.tar.gz<br /> tar -xvzf fcgi-2.4.0.tar.gz<br /> cd fcgi-2.4.0<br /> ./configure && make && make install</code></p> <p><code>cd /root/setup && wget fastcgi.com/dist/mod_fastcgi-2.4.2.tar.gz<br /> tar -xvzf mod_fastcgi-*<br /> cd mod_fastcgi-*<br /> /usr/local/apache/bin/apxs -o mod_fastcgi.so -c *.c<br /> /usr/local/apache/bin/apxs -i -a -n fastcgi mod_fastcgi.so</code></p> <p>E. Install Ruby Gems fcgi:<br /> <code>gem install fcgi</code></p> <p>F. Edit Apache config file:<br /> <code>vi /etc/httpd/conf/httpd.conf</code></p> <p>Find the following (usually I do esc + / and enter SSLL to find this area in httpd.conf file):<br /> <pre style="font-size:11px">SSLLog /usr/local/apache/logs/ssl_engine_log SSLLogLevel info &lt;/IfModule&gt;</pre></p> <p>Enter these lines under the ending &lt;/IfModule&gt; line:<br /> <pre style="font-size:11px">&lt;IfModule mod_fastcgi.c&gt; FastCgiIpcDir /tmp/fcgi_ipc/ AddHandler fastcgi-script .fcgi &lt;/IfModule&gt;</pre></p> <p>Check for the fastcgi apache module entries:<br /> <code>LoadModule fastcgi_module libexec/mod_fastcgi.so</code><br /> and<br /> <code>AddModule mod_fastcgi.c</code></p> <p>G. Make the /tmp/fcgi_ipc/ directory and setup Apache permissions for it:<br /> <code>mkdir -p /tmp/fcgi_ipc<br /> chown nobody:nobody /tmp/fcgi_ipc -R<br /> chmod -755 /tmp/fcgi_ipc -R</code></p> <p>H. Install MySQL for Ruby:<br /> <code>gem install mysql</code></p> <p>Select option 3 for the installation process.</p> <p>I. Install PostGRESQL for Ruby (if you have PostGRESQL on your cPanel Dedicated server):<br /> <code>gem install postgres</code></p> <p>J. Restart Apache:<br /> <code>/etc/init.d/httpd stop<br /> killall -9 httpd<br /> /etc/init.d/httpd startssl</code></p> <p>K. Additional Information:</p> <p><em>Please note that <span style="color:red">user</span> and <span style="color:red">appname</span> should be replaced by the specific account's cPanel username and the application folder name you want to use for your Rails' application.</em></p> <p>a. Make sure Apache can find dispatch.fcgi</em></p> <p>Edit your Rails application’s <strong>/home/user/appname/public/.htaccess</strong> and change the following lines to make sure that the Rails app is using FastCGI.</p> <p>Change:<br /> <code>RewriteRule ^(.*)$ dispatch.cgi?$1 [QSA,L]<br /> to<br /> RewriteRule ^(.*)$ dispatch.fcgi?$1 [QSA,L]</code></p> <p>b. Make sure that <strong>dispatch.fcgi</strong> is executable</em><br /> <code>chmod 755 /home/user/appname/public/dispatch.fcgi</code></p> <p>c. For existing applications:</p> <p>Make sure that your app lives in <strong>/home/user/appname</strong>. Add the following lines in your Rails application’s <strong>/home/user/appname/public/dispatch.fcgi</strong> file:<br /> <code>require 'fcgi'<br /> require 'rubygems'<br /> require_gem 'fcgi'</code></p> <p>d. For a new account, you can test Rails doing the following:<br /> <code>cd /home/user<br /> rails appname<br /> cd appname<br /> ruby script/generate controller test<br /> cd /home/user/public_html<br /> ln -s ../appname/public appname<br /></p> <p>Navigate to <a href="http://domain.com/appname">http://domain.com/appname/</a> and you should see a “Congratulations” page!</p> 88888888888 urn:uuid:5063c7fb-eb52-4d47-99bb-8bb03b89d88c 2008-03-08T19:18:21-08:00 2008-03-08T19:18:21-08:00 Comment on Ruby, Ruby Gems, Rails and FastCGI Installation by 88888888888 cccbvcv m urn:uuid:4f1ea842-0a4b-42f8-a5d7-d0e0b36634fe 2008-03-08T19:18:01-08:00 2008-03-08T19:18:01-08:00 Comment on Ruby, Ruby Gems, Rails and FastCGI Installation by m . , urn:uuid:c801fee6-9040-426d-95d8-d7bbd6c9badb 2008-03-08T19:17:15-08:00 2008-03-08T19:17:15-08:00 Comment on Ruby, Ruby Gems, Rails and FastCGI Installation by , hh , urn:uuid:6f036b22-d0e2-45c2-9edd-38aa4c4c2f29 2008-03-08T19:16:55-08:00 2008-03-08T19:16:55-08:00 Comment on Ruby, Ruby Gems, Rails and FastCGI Installation by , n, dschlenker urn:uuid:5b960ea3-8e0c-4130-aa1d-7c92e9bdc027 2007-07-26T07:48:17-07:00 2007-07-26T07:48:17-07:00 Comment on Ruby, Ruby Gems, Rails and FastCGI Installation by dschlenker new stable version of Ruby, 1.8.5: ftp://ftp.ruby-lang.org/pub/ruby/ruby-1.8.5.tar.gz