Install Rails 3.1 ,Ruby, Mysql, Thinking Sphinx using RVM in Fedora 15

Download the fedora live CD from fedora website


Download Fedora live CD from Fedora Project Website. Install it in your machine.
After the installation goto Applications and search for ‘install to hard disk’ option. Install by chosing the custom option.
* When you try to install using yum and got an error like ‘your username is not in the sudoers file. This incident will be reported’ Then

Edit the sudoers file
To edit it, use the command

gedit /etc/sudoers then if it again shows ‘can’t open the file. You do not have the permissions necessary to open the file’ then

Log in as root (terminal) and type the following:

To get into root type $ su –
password:

then add your username to sudoers file:

$ echo ‘prescience-toshiba ALL=(ALL) ALL’ >> /etc/sudoers

Install RVM and Rails

First Install curl


$ sudo yum install curl

Install git


$ sudo yum install git-core

Install gcc


$ sudo yum install gcc

Install the following dependancies


$ sudo yum install readline-devel.i686
$ sudo yum install zlib
$ sudo yum install sqlite-devel
$ sudo yum install ruby-devel

Then Install RVM


$ bash < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )

Add the following line to your .bash_profile file

[[ -s "/home/prescience-toshiba/.rvm/scripts/rvm" ]] && source "/home/prescience-toshiba/.rvm/scripts/rvm" # This loads RVM into a shell session

replace 'prescience-toshiba' with your username

For ruby 1.9.2 we want the packages it lists under the MRI & ree section. Let’s install those now.

$ sudo yum install bison openssl curl git-core libssl-dev vim libxml2-dev git-core subversion autoconf

Then type
$ rvm list known

Then install ruby 1.9.2


$ rvm install 1.9.2

Type
$ rvm list rubies

You can see ruby versions.

To list default ruby

$ rvm list default

You can change it by
$ rvm –default ruby-1.9.2-p290

Create Gemsets


$ rvm gemset create rails31
$ rvm gemset create rails31rc

$ rvm list gemsets

As a best practice, remember to always use one gemset per project*.
Installing Rails

Select the gemset for Rails 3.1
$ rvm use 1.9.2-p290@rails31rc

for default $ rvm use ruby-1.9.2-p290@rails31rc –default

Installing Rails 3.1


$ gem install rails -v “>=3.1.0.rc4”

If you get an error like

ERROR: Loading command: install (LoadError)
no such file to load — zlib
ERROR: While executing gem … (NameError)
uninitialized constant Gem::Commands::InstallCommand

then install zlib

$ rvm pkg install zlib

then

$ rvm remove 1.9.2
$ rvm install 1.9.2

If the error shows again do

$ sudo yum install zlib zlib-devel

then again do the following

$ rvm remove 1.9.2
$ rvm install 1.9.2

Install Mysql


$ sudo yum -y install mysql-server

See Mysql is running or not
$ sudo netstat -tap | grep mysql
If Yes then you can see like

tcp        0      0 localhost:mysql         *:*                     LISTEN      2556/mysqld

Also install mysql-devel
$ sudo yum install mysql-devel

Start Mysql

$ sudo /etc/rc.d/init.d/mysqld start
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following command:

$ sudo /usr/bin/mysqladmin -u root password ‘new-password’

$ mysql -u root -p
password:

mysql>

Possible errors while doing bundle install and its solutions


1)
checking for rb_thread_blocking_region()… yes
checking for mysql.h… no
checking for mysql/mysql.h… no

—–
mysql.h is missing. please check your installation of mysql and try again.

Install mysql-dev
$ sudo yum install mysql-devel

2)
Installing nokogiri (1.5.0) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

/home/prescience-toshiba/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb
checking for libxml/parser.h… no
—–
libxml2 is missing. please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
—–
*** extconf.rb failed ***
Install the following

$ sudo yum install libxml2-devel libxslt-devel

UPDATE: In Rails 4.2.5 (Ubuntu 14.04), I got the following similar error

Fetching: nokogiri-1.6.7.2.gem (100%)                                                           
Building native extensions.  This could take a while...                                         
ERROR:  Error installing rails:                                                                 
        ERROR: Failed to build gem native extension.                                            
                                                                                                
    current directory: /home/vagrant/.rvm/gems/ruby-2.3.0/gems/nokogiri-1.6.7.2/ext/nokogiri    
/home/vagrant/.rvm/rubies/ruby-2.3.0/bin/ruby -r ./siteconf20160311-22083-xt47t1.rb extconf.rb  
checking if the C compiler accepts ... *** extconf.rb failed ***                                
Could not create Makefile due to some reason, probably lack of necessary                        

Solving this install the following package
$ sudo apt-get install libgmp-dev
3)
Installing therubyracer (0.9.8) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

/home/prescience-toshiba/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb
creating Makefile

make
g++ -I. -I/home/prescience-toshiba/.rvm/gems/ruby-1.9.2-p290@rails31rc/gems/libv8-3.3.10.2-x86-linux/lib/libv8/v8/include -I/home/prescience-toshiba/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/i686-linux -I/home/prescience-toshiba/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/ruby/backward -I/home/prescience-toshiba/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1 -I. -D_FILE_OFFSET_BITS=64 -Wall -g -rdynamic -fPIC -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -fPIC -o v8_date.o -c v8_date.cpp
make: g++: Command not found
make: *** [v8_date.o] Error 127

Install package ‘gcc-c++’ to provide command ‘c++’? [N/y]

$ sudo yum install gcc-c++

Possible errors while using rake command and its solutions


1)
/home/prescience-toshiba/.rvm/gems/ruby-1.9.2-p290@rails31rc/gems/rack-1.3.4/lib/rack/backports/uri/common_192.rb:53: warning: already initialized constant WFKV_
rake aborted!
no such file to load — openssl

2) If you get sprockets error like undefined method static_root
then upgrde your rails to 3.1.0.rc08

3) Started GET “/” for 127.0.0.1 at 2011-10-18 17:47:18 +0530 Mysql2::Error (Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)):

Then make sure that your system have /var/run/mysqld/mysqld.sock file exists. do $ ll /var/run/mysqld/mysqld.sock This will show the details. In my system the mysql.sock is in ‘/var/lib/mysql/mysql.sock’ So create a link to /var/run/mysqld/mysqld.sock from /var/lib/mysql/mysql.sock $ sudo ln -s /var/lib/mysql/mysql.sock /var/run/mysqld/mysqld.sock

$ sudo yum groupinstall development-tools development-libs
$ rvm remove 1.9.2
$ rvm cleanup all
$ rvm install 1.9.2
$ rvm use 1.9.2 –default

Install sphinx


let’s first search for the package

$ yum search sphinx

$ wget http://sphinxsearch.com/files/sphinx-0.9.9.tar.gz

$ ./configure
$ make
$ sudo make install

If shows Error like:

ERROR: cannot find MySQL include files.

Check that you do have MySQL include files installed.
The package name is typically 'mysql-devel'.

If include files are installed on your system, but you are still getting
this message, you should do one of the following:

Then You need to install mysql-devel in fedora
$ sudo apt-get install mysql-devel
OR in Ubuntu
$ $ sudo aptitude install libmysqlclient15-dev

Type
$ search
to see sphinx is installed

how to start mysql at boot time


$ cd /etc/rc.d/rc3.d
$ ln -s /etc/init.d/mysql S98mysql

How does it work? /etc/rc.d/init.d contains scripts to start and stop services on your computer. By creating a symlink to mysql startup script in /etc/rc.d/rc3.d you’re telling your system to run it during runlevel 3 startup, which is your regular login. You can also start and stop your services manually using files in /etc/init.d directly, for example:

$ /etc/init.d/mysql start
$ /etc/init.d/mysql stop

Advertisement

Author: Abhilash

I'm Abhilash, a web developer who specializes in Ruby development. With years of experience working with various frameworks like Rails, Angular, Sinatra, Laravel, NodeJS, React and more, I am passionate about building robust and scalable web applications. Since 2010, I have been honing my skills and expertise in the Ruby on Rails platform. This blog is dedicated to sharing my knowledge and experience on topics related to Ruby, Ruby on Rails, and other subjects that I have worked with throughout my career. Join me on this journey to explore the exciting world of web development!

2 thoughts on “Install Rails 3.1 ,Ruby, Mysql, Thinking Sphinx using RVM in Fedora 15”

  1. Error Downloading Packages:
    gcc-4.6.2-1.fc16.i686: failure: Packages/gcc-4.6.2-1.fc16.i686.rpm from fedora: [Errno 256] No more mirrors to try.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: