Install Ruby on Rail, Apache 2.2.3, Fastcgi 2.4.2 on Linux

Tagged:

You should consider install fcgid instead of fastcgi because fastcgi is so out of date.

Here is the quick guide for FCGID. For fastcgi, see the bottom of this article.

Here is the FCGID guide.
http://wiki.rubyonrails.org/rails/pages/HowtoSetupApacheWithFastCGIAndRubyBindings

--------------------------------------
Ruby on Rails and FastCGI -- BELOW
--------------------------------------
Here is a quick guide on how to install Ruby on Rail, Apache and Fastcgi.

  1. Login as ROOT
  2. First install Ruby on Rail
    1. Make sure you have Ruby on the system. If not, download it from: http://rubyforge.org/frs/download.php/7858/ruby-1.8.4.tar.gz
    2. Compile and install.
    3. Install Ruby Gem from here: http://rubyforge.org/frs/?group_id=126 Compile and Install.
    4. Then type: gem install rails --include-dependencies
    5. To test it, type the following:
      1. cd /tmp
      2. rails first
      3. cd first
      4. ./script/server
      5. Point your browser to http://hostname:3000/ and you will see the ruby welcome page
  3. Install Apache 2.2.3
    1. download Apache 2.2.3 from here: http://httpd.apache.org/download.cgi
    2. unzip it and type: ./configure --enable-mods-shared=all --enable-so --enable-rewrite
    3. type: make ; make install
    4. Your Apache server should be installed at : /usr/local/apache2
    5. type: /usr/local/apache2/bin/apachectl start
    6. Point the browser to: http://hostname/ and you should see the apache welcome message.
  4. Install Fastcgi for Apache
    1. Download it from: http://www.fastcgi.com/dist/mod_fastcgi-2.4.2.tar.gz\r\n
    2. unzip it and type: cp Makefile.AP2 Makefile
    3. Since Apache 2.x changes the API setting, you need to add this to fcgi.h in order to build Fastcgi with Apache.
      #ifndef ap_copy_table
      #define ap_copy_table apr_table_copy
      #define ap_cpystrn apr_cpystrn
      #define ap_destroy_pool apr_pool_destroy
      #define ap_isspace apr_isspace
      #define ap_make_array apr_array_make
      #define ap_make_table apr_table_make
      #define ap_null_cleanup apr_pool_cleanup_null
      #define ap_palloc apr_palloc
      #define ap_pcalloc apr_pcalloc
      #define ap_psprintf apr_psprintf
      #define ap_pstrcat apr_pstrcat
      #define ap_pstrdup apr_pstrdup
      #define ap_pstrndup apr_pstrndup
      #define ap_push_array apr_array_push
      #define ap_register_cleanup apr_pool_cleanup_register
      #define ap_snprintf apr_snprintf
      #define ap_table_add apr_table_add
      #define ap_table_do apr_table_do
      #define ap_table_get apr_table_get
      #define ap_table_set apr_table_set
      #define ap_table_setn apr_table_setn
      #define ap_table_unset apr_table_unset
      
      #endif /* defined(ap_copy_table) */
      
    4. type: make ; make install
    5. make sure mod_fastcgi.so is copied to /usr/local/apache2/modules/
    6. Make a directory /tmp/fcgi_ipc
    7. Add this in /usr/local/apache2/conf/httpd.conf
      LoadModule fastcgi_module  modules/mod_fastcgi.so
      <IfModule mod_fastcgi.c>
           FastCgiIpcDir /tmp/fcgi_ipc/
           AddHandler fastcgi-script .fcgi .fcg .fpl
      </IfModule>
      
      Alias /first/ "/tmp/first/public"
      Alias /first "/tmp/first/public"
      
      <Directory /tmp/first/public/>
          Options ExecCGI FollowSymLinks
          AllowOverride all
          Order allow,deny
          Allow from all
      </Directory>
      
    8. In /tmp/first/public directory, there is a file call .htaccess.
      1. change RewriteRule ^(.*)$ dispatch.cgi [QSA,L] to RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
      2. then change # RewriteBase /myrails to RewriteBase /first
    9. Restart apache by: /usr/local/apache2/bin/apachctl restart
    10. Point your browser to: http://hostname/first/
    11. Done. Now, you have RoR, Apache and Fastcgi.