i TRY TO CONFIGURE APACHE FOR RUBY ON RAILS ON UNIX.
BY THE FOLLOWING WAYl:
Install FastCGI
- wget http://www.fastcgi.com/dist/fcgi-2.4.0.tar.gz
- gunzip fcgi-2.4.0.tar.gz
- tar -xvf fcgi-2.4.0.tar
- cd fcgi-2.4.0
- ./configure
- make
- make install
- cd …/
Install mod_fcgid
-
cd ~
-
gunzip mod_fcgid.1.09.tar.gz
-
tar -xvf mod_fcgid.1.09.tar
-
cd mod_fcgid.1.09
-
vi Makefile
Change top_dir to:top_dir = /usr/lib/httpd
Uncomment #INCLUDES and change to
INCLUDES=-I /usr/include/httpd -I /usr/include/apr-0
-
make
-
make install
-
cd …/
Install Ruby
- cd /etc/yum.repos.d/
- wget http://dev.centos.org/centos/4/CentOS-Testing.repo
- yum --enablerepo=c4-testing install ruby ruby-docs ri ruby-libs
ruby-mode ruby-tcltk irb rdoc ruby-devel
Install Ruby Gems
- wget
http://rubyforge.org/frs/download.php/11289/rubygems-0.9.0.tgz - tar -xzf rubygems-0.9.0.tgz
- cd rubygems-0.9.0
- ruby setup.rb
- cd …/
Install Rails, FastCGI, and Mysql
-
gem install rails --include-dependencies
-
gem install fcgi
-
gem install mysql – --with-mysql-config=/usr/bin/mysql_config
- Select option 1 – mysql 2.7.1 (ruby)
-
vi /etc/ld.so.conf
Add line:/usr/local/lib
-
/sbin/ldconfig
Create Test Application – this will get you started on the popular
“cookbook†tutorial from OnLamp.
- mkdir /var/www/rails
- cd /var/www/rails/
- rails cookbook
Set Permissions on Test Application
- chgrp -R apache cookbook/
- chmod -R g+r cookbook/
- chmod -R g+w cookbook/log/
- chmod -R g+w cookbook/tmp/
- find /var/www/rails/cookbook/ -type d -exec chmod g+x {} ;
Configure Apache
-
vi /etc/httpd/conf.d/fcgid.conf
Insert the following:LoadModule fcgid_module /usr/lib/httpd/modules/mod_fcgid.so
SocketPath /tmp/fcgid_sock/ AddHandler fcgid-script .fcgi -
vi /etc/httpd/conf.d/hosts.conf
(Personally, I put all my custom Apache configuration in this file
to keep things organized)
Insert the following:<VirtualHost *:80>
SetEnv RAILS_ENV development
ServerName dnsnameoripaddress
DocumentRoot /var/www/rails/cookbook/public/
ErrorLog /var/www/rails/cookbook/log/apache.log<Directory /var/www/rails/cookbook/public/>
Options ExecCGI FollowSymLinks
AddHandler fcgid-script .fcgi
AllowOverride all
Order allow,deny
Allow from all
-
vi /var/www/rails/cookbook/public/.htaccess
Change line:RewriteRule ^(.*)$ dispatch.cgi [QSA,L]
to
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
And change:
AddHandler fastcgi-script .fcgi
to
AddHandler fcgid-script .fcgi
do NOT change the require line as other guides tell you to do.
Hello, World!
-
cd /var/www/rails/cookbook/
-
ruby script/generate controller mytest
-
vi app/controllers/my_test_controller.rb
Change file to read:class MyTestController < ApplicationController
def index
render_text => “Hello World!”
end
end -
/sbin/service httpd start
BUT AT LAST IS ACTION CONTROLLER EXCEPTION AND PAGE IS REDIRECTED OTHER
SITES.
THIS CONFIGURATION DO NOT .
IS CONFIGURING APACHE FOR RUBY ON RAILS IS POSSIBLE OR NOT
IFF POSSIBLE PLEASE FORWARD ME THE APPROPIATE LINKS FOR WINDOW AND UNIX
PLATEFORM