Rails development environment
Added 28.01.2012 by Peter Davidse.
Installation of rvm, rails, postgresql and eclipse/radrails on Fedora 16 (LXDE) & Centos 5.x / 6.x
![]() |
| Screenshot of the obtained result (click here for a bigger picture) |
Why i wrote this?!
I am developing a new website with a lot more (database) features, The PHP based solution i use at the moment does not suit my needs.
During my transition to Ruby on Rails (RoR) i had a lot of problems getting the development environment and webserver(s) to work with RoR and i want to help you out so you do not waste time.
This procedure takes no more than 2 hours, probably much less...
This installation procedure is done on Fedora 16 LXDE Linux and works great on Centos / RedHat EL 5.x / 6.x.
When using Centos / RedHat the groupinstall packages have a different name and i have not bothered to lookup what these names are.
Lower versions of Fedora should work but i have not tested this.
I choose Fedora 16 above other distribution because i needed a hassle free Ruby on Rails environment.
After testing all Fedora 16 flavours, LXDE gave the best user experiance and performance, really low cpu usage :-D
This procedure works on the other flavors of Fedora 16 (Gnome, XFCE and KDE), but have proven to be unusable due to the GUI design.
Fedora 16 with Gnome is unusable in my opinion; it sucks big time!
A note on security; always check and see if the solution is safe for your environment!!!
I do not take any responsibility, this howto is about installing a development environment, not production!!!
Just an open door; do not type "[root@devil] #", this is the Linux prompt, but you know that already ;-)
BTW : devil is short for "development in linux", not the name of the fictional figure!
At the time i wrote this RoR is at version 3.2.0 and Ruby is at version 1.9.3.
Because PostgreSQL is my database system of choise i have added the installation of PostgreSQL as well!
This is procedure is tested and working with PostgreSQL 8.4 and 9.1.2.
MySQL should work as well but because i do not use it, i do not write about it.
Sqlite is added because of possible compatibility issues.
And now, get to work...
OS preparation
Download and install Fedora 16 or use your existing installation.
When using a new install:
Add your user to the administrator group when you add a user in the welcome screen!
This is a tickbox on the right side next to the username box.
Doing this makes you life easier later on.
On other distro's or when adding new users, add them to the "wheel" group, they get elevated rights.
Make sure to edit the sudoers file in case this is needed in your installation.
Note : For the whole sessian i "su" to be root user, use this with care!
Installing all the needed packages:
[peter@devil]$ su -
Password: <password>
[root@devil]#
Update your system after installation / use:
[root@devil]# yum clean all
[root@devil]# yum update -y
Reboot your system in case of a new kernel to activate it (recommended):
[root@devil]# reboot
After the reboot, install neccessary packages:
[root@devil]# yum groupinstall "Development Tools" "Development Libraries" "PostgreSQL Database" -y
[root@devil]# yum install pgadmin3 postgresql-devel sqlite sqlite-devel eclipse -y
Installing rvm, ruby and rails
[root@devil]# bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )
Note: remember to exit the su session and "su -" again to refresh the environment.
[root@devil ]# rvm --skip-autoreconf pkg install readline
[root@devil ]# rvm install 1.9.3
[root@devil ]# rvm use 1.9.3 --default
Note: i used 1.9.3 as Ruby version but you are free to use another one, or install other version along side each other.
Now install the latest version of Ruby on Rails:
[root@devil ]# gem install rake rails pg execjs therubyracer
Create a new rails project in eg. your homedir
[peter@devil ]$ rails new <projectname> -d postgresql
Add the following to the Gemfile to get bundle, rake and rails to work properly:
gem 'execjs'
gem 'therubyracer'
Add some usefull aliases to .bashrc
edit your default users .bashrc with your favorite editor and add some aliases to make you life easier
#-----------------------------------------------------------------------------#
# Rails aliases and functions
#-----------------------------------------------------------------------------#
alias rc='rails console'
alias rs='rails server'
alias rd='rails db'
alias rdm='rake db:migrate'
... feel free to add your own lazy keys :-)
Postgresql installation
Skip this line when you have existing databases.
[root@devil]# postgresql-setup initdb
Handy symbolic link:
[root@devil]# ln -s /var/lib/pgsql/data /etc/postgresql
[root@devil]# cd /etc/postgresql
Edit pg_hba.conf:
local all all trust
host all all 127.0.0.1/32 trust
host all all ::1/128 trust
Edit postgresql.conf:
listen_addresses = 'localhost'
or
listen_addresses = '*'
port = 5432
[root@devil]# systemctl enable postgresql.service
[root@devil postgresql] service postgresql start
[root@devil]# su - postgres
-bash-4.2$ createuser --superuser <user>
-bash-4.2$ psql template1
template1=# \password <user>
Enter new password: <password>
Enter it again: <password>
template1=# \q
.bash-4.2$ exit
[root@devil postgresql] service postgresql reload
Your PostgreSQL installation is ready to rock!
TIP: use pgadmin3 to administer your database server(s) and schema(s).
Eclipse configuration
Start eclipse from the "programming" menu and do the following once started.
Goto Help->Install New Software->"click Add"
In "Location:" write "http://download.aptana.com/studio3/plugin/install"
click OK and follow the "wizard".
Once installled and restarted, you are good to go on your brand new development installation.
--enjoy!
TIP: if you want to use apache or nginx as your webserver, install passenger, this is a worry free solution!
TIP: use git to do version tracking and use it to deploy to you production environment!
if you have question or just want to say you liked this post, feel free to mail me:

