Using FastCGI on cPanel
From OCS Support Wiki
Contents |
[edit] Introduction
Using FastCGI instead of regular CGI mode is faster, as the Ruby interpreter doesn't have to be loaded each time your site is accessed.
[edit] Switching to FastCGI
Changing over from CGI to FastCGI for your Ruby on Rails application is easy. Simply open up the .htaccess file in the public directory of your Rails app and look for a line like this:
RewriteRule ^(.*)$ dispatch.cgi [QSA,L]
You will find this around line 32 of the default .htaccess file that ships with Rails. Change this to read:
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
On some servers, you may have to change:
AddHandler fastcgi-script .fcgi
to
AddHandler fcgid-script .fcgi
Your application should now run with FastCGI, responding much quicker, especially on subsequent page visits (the first time you visit the page when you've just enabled FastCGI, the Ruby interpreter will have to be loaded)
NOTE: You CANNOT use this for anything other than production mode. See config/environment.rb for changing your mode to "production".
[edit] Restarting your FastCGI Process
If you need to restart your FastCGI process, simply establish an SSH connection and run:
killall -9 dispatch.fcgi ruby
This will kill your dispatcher and the next time you visit the site it will be reloaded. Note that you will see errors like "Permission denied" when running this command, but that is normal.
[edit] Switching Back to CGI
If you need to do any development work, it is required that you switch back to CGI mode. Simply edit the .htaccess file again in the public_html directory and change the dispatch.fcgi back to dispatch.cgi around line 32.
