These instructions shouldn’t be particular to Red Hat though because of cPanels “EasyApache” things go arwy when installing mod_fastcgi
These instructions assume you are running as a superuser.
Install Ruby:
(You can grab the latest source package from http://ruby-lang.org/en/20020102.html)
$ cd /usr/local/src
$ wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.4.tar.gz
$ tar -xvzf ruby-1.8.4.tar.gz
$ cd ruby-1.8.4
$ ./configure && make && make install
Next Ruby Gems:
(Latest version and localized mirrors here http://rubyforge.org/frs/?group_id=126 )
$ cd /usr/local/src
$ wget rubyforge.org/frs/download.php/11289/rubygems-0.9.0.tgz
$ tar -xvzf rubygems-0.9.0.tgz
$ cd rubygems-0.9.0
$ ruby setup.rb
Once Gems are installed its a whirl to install Rails:
$ gem install rails --include-dependencies
Now for FastCGI? and getting it to play nicely with Apache.
Install FastCGI?:
(‘Sourced’ from http://fastcgi.com/dist/)
$ cd /usr/local/src
$ wget fastcgi.com/dist/fcgi-2.4.0.tar.gz
$ tar -xvzf fcgi-2.4.0.tar.gz
$ cd fcgi-2.4.0
$ ./configure && make && make install
And mod_fastcgi for Apache 1.3+
I installed mod_fastcgi as a DSO.
Because cPanel uses EasyApache the location of apxs is different so these instructions deviate somewhat from the INSTALL docs. (ymmv!)
$ cd /usr/local/src
$ wget fastcgi.com/dist/mod_fastcgi-2.4.2.tar.gz
$ tar -xvzf mod_fastcgi-2.4.2.tar.gz
$ cd mod_fastcgi-2.4.2
$ /usr/local/apache/bin/apxs -o mod_fastcgi.so -c *.c
$ /usr/local/apache/bin/apxs -i -a -n fastcgi mod_fastcgi.so
Now for Ruby fcgi:You could 0.8.6.1 is now in the gem repository.gem install fcgi but that currently installs version 0.8.5, so I’d reccomend compiling 0.8.6 from source as below.
$ gem install fcgi
You now need to edit your Apache config file.
By default its (/usr/local/apache/conf/httpd.conf)
Add these lines: (tweak the last line accordingly, comments are welcome)
LoadModule fastcgi_module libexec/mod_fastcgi.so
<IfModule mod_fastcgi.c>
FastCgiIpcDir /tmp/fcgi_ipc/
AddHandler fastcgi-script .fcgi
</IfModule>
FastCgiConfig -maxClassProcesses 20 -maxProcesses 20 -minProcesses 1 -processSlack 1 -initial-env RAILS_ENV=production -idle-timeout 120
Make sure /tmp/fcgi_ipc/ is writable and executable by Apache
(Apache runs as ‘nobody’ on my Machine, this may differ for you)
$ mkdir -p /tmp/fcgi_ipc
$ chown nobody.nobody /tmp/fcgi_ipc -R
$ chmod 755 /tmp/fcgi_ipc -R
Now restart Apache:
$ /etc/rc.d/init.d/httpd restart
Ruby on Rails should now be successfully installed.
To use an existing application Make sure that your app lives in /home/USER/testapp Change the line in your Rails application’s public/dispatch.fcgi
Change:
require 'fcgi'
To:
require 'fcgi'
require 'rubygems'
require_gem 'fcgi'
Make sure Apache can find dispatch.fcgi
Now edit your app’s public/.htaccess and change/add the following lines to make sure that the Rails app is using FastCGI and that it knows that the app is living in a subdirectory.
Change:
RewriteRule ^(.*)$ dispatch.cgi?$1 [QSA,L]
To:
RewriteBase /testapp
RewriteRule ^(.*)$ dispatch.fcgi?$1 [QSA,L]
Make sure that dispatch.fcgi is executable:
$ chmod 755 public/dispatch.fcgi
All should be installed! :)
For a new account, you can test RoR out by creating a test cPanel account and doing:
$ cd /home/USER
$ rails /home/USER/testapp
$ cd /home/USER/testapp/
$ ruby script/generate controller test
$ cd /home/USER/public_html
$ ln -s ../testapp/public rails
Replace USER with an appropriate username ;)
Then naviagte to http://www.yourtestdomain.com/rails/ and you should see a “Congratulations” page!
Note: This isn’t an ideal solution for hosting clients ruby apps, you should look toward a lighttpd mod_proxy solution for this.
Taken From: [link dead] http://blog.e-reet.org/archives/ruby-on-rails-on-cpanel
require 'fcgi'
require 'rubygems'
require_gem 'fcgi'
Also, I have noticed that I was only able to get things going by adding this in httpd.conf instead of the lines mentioned above (in IfModule tag)
<IfModule mod_fastcgi.c>
FastCgiIpcDir /tmp/fcgi_ipc/
AddHandler fastcgi-script .fcgi
FastCgiWrapper On
FastCgiConfig -autoUpdate -singleThreshold 100 -killInterval 300 -idle-timeout 240
</IfModule>
Hope this helps.
Adding those lines in httpd.conf on cpanel stopped apache starting. It starts ok with this format though:
LoadModule fastcgi_module ibexec/mod_fastcgi.so
After the other LoadModule entries.
FastCgiIpcDir /tmp/fcgi_ipc/
AddHandler fastcgi-script .fcgi
After the AddModule entries. The testapp example at http://www.mytestdomain.com/rails just gives me:
Bad Request
Your browser sent a request that this server could not understand.
I can save a “Hello World” script though and execute it at the command line:
test.rb
puts "Hello, World!"
#ruby test.rb
Hello, World!
So Ruby appears to be working – just not through the browser. Any ideas appreciated
Bad Request
Your browser sent a request that this server could not understand.
RewriteBase /testapp
RewriteRule ^(.*)$ dispatch.fcgi?$1 [QSA,L]
use just:
RewriteRule ^(.*)$ dispatch.fcgi?$1 [QSA,L]
If I type in http://domain/rails/index.html i get the rails page
I’m running Apache 2.2,
Yeah, I did this:
Executed /scripts/installruby
gem install rails—include-dependencies
$ cd /home/USER
$ rails /home/USER/testapp
$ cd /home/USER/testapp/
$ ruby script/generate controller test
$ cd /home/USER/public_html
$ ln -s ../testapp/public rails
And everything works fine… it took 2 minutes… have I missed something?—rosslittle@gmail.com
—
I couldn’t get anything working on my CPanel VPS until I changed the owner of the application.
chown -R user:user RAILS_APP
These instructions shouldn’t be particular to Red Hat though because of cPanels “EasyApache” things go arwy when installing mod_fastcgi
These instructions assume you are running as a superuser.
Install Ruby:
(You can grab the latest source package from http://ruby-lang.org/en/20020102.html)
$ cd /usr/local/src
$ wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.4.tar.gz
$ tar -xvzf ruby-1.8.4.tar.gz
$ cd ruby-1.8.4
$ ./configure && make && make install
Next Ruby Gems:
(Latest version and localized mirrors here http://rubyforge.org/frs/?group_id=126 )
$ cd /usr/local/src
$ wget rubyforge.org/frs/download.php/11289/rubygems-0.9.0.tgz
$ tar -xvzf rubygems-0.9.0.tgz
$ cd rubygems-0.9.0
$ ruby setup.rb
Once Gems are installed its a whirl to install Rails:
$ gem install rails --include-dependencies
Now for FastCGI? and getting it to play nicely with Apache.
Install FastCGI?:
(‘Sourced’ from http://fastcgi.com/dist/)
$ cd /usr/local/src
$ wget fastcgi.com/dist/fcgi-2.4.0.tar.gz
$ tar -xvzf fcgi-2.4.0.tar.gz
$ cd fcgi-2.4.0
$ ./configure && make && make install
And mod_fastcgi for Apache 1.3+
I installed mod_fastcgi as a DSO.
Because cPanel uses EasyApache the location of apxs is different so these instructions deviate somewhat from the INSTALL docs. (ymmv!)
$ cd /usr/local/src
$ wget fastcgi.com/dist/mod_fastcgi-2.4.2.tar.gz
$ tar -xvzf mod_fastcgi-2.4.2.tar.gz
$ cd mod_fastcgi-2.4.2
$ /usr/local/apache/bin/apxs -o mod_fastcgi.so -c *.c
$ /usr/local/apache/bin/apxs -i -a -n fastcgi mod_fastcgi.so
Now for Ruby fcgi:You could 0.8.6.1 is now in the gem repository.gem install fcgi but that currently installs version 0.8.5, so I’d reccomend compiling 0.8.6 from source as below.
$ gem install fcgi
You now need to edit your Apache config file.
By default its (/usr/local/apache/conf/httpd.conf)
Add these lines: (tweak the last line accordingly, comments are welcome)
LoadModule fastcgi_module libexec/mod_fastcgi.so
<IfModule mod_fastcgi.c>
FastCgiIpcDir /tmp/fcgi_ipc/
AddHandler fastcgi-script .fcgi
</IfModule>
FastCgiConfig -maxClassProcesses 20 -maxProcesses 20 -minProcesses 1 -processSlack 1 -initial-env RAILS_ENV=production -idle-timeout 120
Make sure /tmp/fcgi_ipc/ is writable and executable by Apache
(Apache runs as ‘nobody’ on my Machine, this may differ for you)
$ mkdir -p /tmp/fcgi_ipc
$ chown nobody.nobody /tmp/fcgi_ipc -R
$ chmod 755 /tmp/fcgi_ipc -R
Now restart Apache:
$ /etc/rc.d/init.d/httpd restart
Ruby on Rails should now be successfully installed.
To use an existing application Make sure that your app lives in /home/USER/testapp Change the line in your Rails application’s public/dispatch.fcgi
Change:
require 'fcgi'
To:
require 'fcgi'
require 'rubygems'
require_gem 'fcgi'
Make sure Apache can find dispatch.fcgi
Now edit your app’s public/.htaccess and change/add the following lines to make sure that the Rails app is using FastCGI and that it knows that the app is living in a subdirectory.
Change:
RewriteRule ^(.*)$ dispatch.cgi?$1 [QSA,L]
To:
RewriteBase /testapp
RewriteRule ^(.*)$ dispatch.fcgi?$1 [QSA,L]
Make sure that dispatch.fcgi is executable:
$ chmod 755 public/dispatch.fcgi
All should be installed! :)
For a new account, you can test RoR out by creating a test cPanel account and doing:
$ cd /home/USER
$ rails /home/USER/testapp
$ cd /home/USER/testapp/
$ ruby script/generate controller test
$ cd /home/USER/public_html
$ ln -s ../testapp/public rails
Replace USER with an appropriate username ;)
Then naviagte to http://www.yourtestdomain.com/rails/ and you should see a “Congratulations” page!
Note: This isn’t an ideal solution for hosting clients ruby apps, you should look toward a lighttpd mod_proxy solution for this.
Taken From: [link dead] http://blog.e-reet.org/archives/ruby-on-rails-on-cpanel
require 'fcgi'
require 'rubygems'
require_gem 'fcgi'
Also, I have noticed that I was only able to get things going by adding this in httpd.conf instead of the lines mentioned above (in IfModule tag)
<IfModule mod_fastcgi.c>
FastCgiIpcDir /tmp/fcgi_ipc/
AddHandler fastcgi-script .fcgi
FastCgiWrapper On
FastCgiConfig -autoUpdate -singleThreshold 100 -killInterval 300 -idle-timeout 240
</IfModule>
Hope this helps.
Adding those lines in httpd.conf on cpanel stopped apache starting. It starts ok with this format though:
LoadModule fastcgi_module ibexec/mod_fastcgi.so
After the other LoadModule entries.
FastCgiIpcDir /tmp/fcgi_ipc/
AddHandler fastcgi-script .fcgi
After the AddModule entries. The testapp example at http://www.mytestdomain.com/rails just gives me:
Bad Request
Your browser sent a request that this server could not understand.
I can save a “Hello World” script though and execute it at the command line:
test.rb
puts "Hello, World!"
#ruby test.rb
Hello, World!
So Ruby appears to be working – just not through the browser. Any ideas appreciated
Bad Request
Your browser sent a request that this server could not understand.
RewriteBase /testapp
RewriteRule ^(.*)$ dispatch.fcgi?$1 [QSA,L]
use just:
RewriteRule ^(.*)$ dispatch.fcgi?$1 [QSA,L]
If I type in http://domain/rails/index.html i get the rails page
I’m running Apache 2.2,
Yeah, I did this:
Executed /scripts/installruby
gem install rails—include-dependencies
$ cd /home/USER
$ rails /home/USER/testapp
$ cd /home/USER/testapp/
$ ruby script/generate controller test
$ cd /home/USER/public_html
$ ln -s ../testapp/public rails
And everything works fine… it took 2 minutes… have I missed something?—rosslittle@gmail.com
—
I couldn’t get anything working on my CPanel VPS until I changed the owner of the application.
chown -R user:user RAILS_APP