Install a Rails stack on Fedora Core
I begin here a serie of articles about Installing Rails stack on several platforms, for different purposes (development, production). I will continue with the detail of a current RoR application we just launched here, by my client, then how to deploy it on the production server using Capistrano 2, and how to configure Apache 2 to make it run with FastCGI.
The RoR application is developed on our Linux desktops, is hosted on the remote “low cost” Subversion server (BeansTalkApp), the application is deployed with Capistrano 2 to a Linux Debian virtualized server into the DMZ and is running on Apache 2 + FastCGI.
First , i begin with an install of Ruby, Rails, mySQL, Lighttpd done on my desktop running on Linux Fedora Core 7.
On Fedora, as you had on RedHat with RPMs ( and as you have on Debian with Aptitude), you can use the package manager called ‘yum’. Here are the steps to follow to get a functional RoR stack ready.
Install Ruby:
Launch the command in a terminal window (we’re connected as root):
$ yum install ruby ruby-devel ruby-libs irb rdoc
Installed: ruby-devel.i386 0:1.8.6.114-1.fc7 ruby-devel.x86_64
0:1.8.6.114-1.fc7 ruby-rdoc.x86_64 0:1.8.6.114-1.fc7
Dependency Installed: ruby.x86_64 0:1.8.6.114-1.fc7 ruby-irb.x86_64
0:1.8.6.114-1.fc7 ruby-libs.i386 0:1.8.6.114-1.fc7 ruby-libs.x86_64
0:1.8.6.114-1.fc7
Install RubyGems
$ cd /tmp
$ wget http://rubyforge.org/frs/download.php/35283/rubygems-1.1.1.tgz
$ tar xzvf rubygems
$ cd rubygems-1.1.1
$ ruby setup.rb
$ cd ..
$ rm rubygem* -drf
Install Rails
We first install the 1.2.3 release of Rails , because of one of our server, running Rails app in version 1.2.3
$ gem install rails -v 1.2.3 –include-dependencies
Update to Rails 2.x
$ gem update rails –include-dependencies
Install lighttpd
$ yum install lighttpd lighttpd-fastcgi
Install FastCGI:
$ wget http://www.fastcgi.com/dist/fcgi.tar.gz
$ tar xzvf fcgi-2.4.0.tar.gz
$ cd fcgi-2.4.0/
$ ./configure
$ make
$ make install
$ cd ..
$ rm fcgi* -drf
Install Ruby FastCGI Bindings
$ wget http://sugi.nemui.org/pub/ruby/fcgi/ruby-fcgi-0.8.6.tar.gz
$ tar xzvf ruby-fcgi-0.8.6.tar.gz
$ cd ruby-fcgi-0.8.6
$ ruby install.rb config
$ ruby install.rb setup
$ ruby install.rb install
$ cd ..
$ rm ruby-fcgi* -drf
Install MySQL:
$ yum install mysql mysql-server mysql-devel mysql-administrator
Start Lighttpd + mySQL
You can do it by opening “Services” Client
Secure mySQL (set password for root)
$ mysql -uroot -p
mysql> SET PASSWORD FOR root@localhost=PASSWORD(’<newPassword>’);
mysql> exit
$ mysql -uroot -p<newPassword>
Now the base is ready we need to do some configuration.
I use the IDE Netbeans 6 to develop my RoR applications. Download and Install Netbeans 6
Install if needed Subversion client
Setup your Subversion repository on http://www.beanstalkapp.com/
As our application is light, we keep the free beansTalk account : 20MB quota, 3 users (including the Anonymous user with read access)
After your setup, you should access your Subversion repository http://<appname>.svn.beanstalkapp.com/<repos>
For checkout only, if you enabled the Anonymous user
Use your users credentials, to checkout, commit, update.
Checkout the empty project :
$ cd ~/workspace; mkdir <app name>; cd <app name>
$ export REPOS=http://<app name>.svn.beanstalkapp.com/<repos>
$ svn co $REPOS/trunk .
Before doing the first import, we first create the skeleton of the Rails application on our desktop.
$ cd ~/workspace
$ rails <app name>
$ cd <app name>
$ svn add –force .
Before commit we should ignore some files:
$ svn revert log/*
Reverted ‘log/development.log’
Reverted ‘log/fastcgi.crash.log’
Reverted ‘log/lighttpd.access.log’
Reverted ‘log/lighttpd.error.log’
Reverted ‘log/production.log’
Reverted ‘log/server.log’
Reverted ‘log/test.log’
$ svn propset svn:ignore “*.log” log
property ’svn:ignore’ set on ‘log’
$ svn revert config/database.yml
Reverted ‘config/database.yml’
$ cp database.yml database.yml.template
$ svn add database.yml.template
$ svn propset svn:ignore “database.yml” config
Ignore db/schema.rb, tmp/* , doc, script, public
$ svn propset svn:ignore “schema.rb” config
$ svn propset svn:ignore “*” tmp
$ svn propset svn:ignore “*doc” doc
Flag as executables script/* and public/dispatch.*
$ svn propset svn:executable “*” `find script -type f | grep -v ‘.svn’` public/dispatch.*
Finally, revert and remove index.html (we’ll do a route for the application)
$ svn revert public/index.html
$ rm public/index.html
$ svn commit –message=”First import project <app name>”
Open your IDE then create your working copy by checkout.
Configure your local mySQL database with the three databases (development, test, production)
$ mysql -uroot mysql
mysql> create database <app name>_development;
mysql> create database <app name>_test;
mysql> create database <app name>_production;
mysql> GRANT ALL PRIVILEGES ON <app name>_development.* TO ‘<my app User>’@'localhost’ IDENTIFIED BY ‘newPassword’ WITH GRANT OPTION;
mysql> GRANT ALL PRIVILEGES ON <app name>_test.* TO ‘<my app User>’@'localhost’ IDENTIFIED BY ‘newPassword’ WITH GRANT OPTION;
mysql> GRANT ALL PRIVILEGES ON <app name>_test.* TO ‘<my app User>’@'localhost’ IDENTIFIED BY ‘newPassword’ WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;
mysql> exit
Create a copy of <app name>/config/database.yml.template to <app name>/config/database.yml
Setup your database connections :
development:
adapter: mysql
database: <app name>_development
username: <my app user>
password: <my app user pwd>
socket: /var/run/mysqld/mysqld.sock
test:
adapter: mysql
database: <app name>_test
username: <my app user>
password: <my app user pwd>
socket: /var/run/mysqld/mysqld.sock
production:
adapter: mysql
database: <app name>_production
username: <my app user>
password: <my app user pwd>
socket: /var/run/mysqld/mysqld.sock
Start your WebRick Server and test your application :
$ cd /path/to/your/app; script/server
Open a browser and go to http://localhost:3000/ to see the welcome page
June 13, 2008 at 10:11 am
[...] A first one about installing a rails stack on Fedora core 7/8 [...]