Install Fedena on CentOS

Installing Fedena on Centos is a bit tricky since most of the stack used to run fedena is not available as packages and has to be compiled and installed from their sources. The Centos version 6.7, the version I used to test fedena, comes with a version of Ruby that is very old. So here is what you should do to get Fedena up and running. First the plan. Our plan is to install the Centos, Nginx (and passenger), MySQL and RoR stack and then install fedena. The instructions here are for installing on a VPS with a VM, installing it on your laptop or other hardware is similar.

Assuming that you have a working installion of Centos either on your laptop, server or a VM on the cloud here are the activities that you should do to get fedena up and running.

Installing Ruby and Rails

Fedena requires Ruby 1.8.7 and Rails 2.3.5, The version numbers are extremely important and you should verify that these specific versions of ruby and rails have been installed before you proceed executing the subsequent steps.

yum install -y gcc zlib zlib-devel
wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p352.tar.gz
tar xvf ruby-1.8.7-p352.tar.gz
cd ruby-1.8.7-p352
./configure --enable-pthread 
make
make install

Do a check on the version of ruby installed

# ruby -v
ruby 1.8.7 (2010-12-23 patchlevel 352) [x86_64-linux]

If you have a 64bit version of Centos you can make it a 64bit version

[[email protected] ruby-1.8.7-p352]# cd ext/zlib
[[email protected] ruby-1.8.7-p352]# ruby extconf.rb --with-zlib-include=/usr/include --with-zlib-lib=/usr/lib64
[[email protected] ruby-1.8.7-p352]# cd ../../
[[email protected] ruby-1.8.7-p352]# make
[[email protected] ruby-1.8.7-p352]# make install

Check the version of ruby, again

[[email protected] ruby-1.8.7-p352]# ruby -v
ruby 1.8.7 (2010-12-23 patchlevel 352) [x86_64-linux]
Installing rubygems

After installing ruby you should install ruby gems. Like in the case of ruby, you should install ruby gems from source because the packages install a very old version of ruby gems. First download the source code from the repository to a directory "source" or "src". If you haven't got a directory then create one then make that directory your present working directory.

[[email protected] ruby-1.8.7-p352]# cd /usr/local/src

Fedena requires ruby gems 1.3.7 so lets download it

wget http://production.cf.rubygems.org/rubygems/rubygems-1.3.7.tgz

Unpack the sources. Once done you should see a directory rubygems-1.3.7.

[[email protected] src]# tar -zxvf rubygems-1.3.7.tgz 
[[email protected] src]# cd rubygems-1.3.7

Compile and install rubygems

[[email protected] rubygems-1.3.7]# sudo ruby setup.rb

You should see the following message and some information on notes and bugs

RubyGems 1.3.7 installed

=== 1.3.7 / 2010-05-13

Check the gems version

[[email protected] rubygems-1.3.7]# gem -v

You should see

1.3.7

So far so good

Now install the gem: prawn. Ensure you install the specific version mentioned here.

[[email protected] projectfedena-projectfedena_v2.0-a213125]# gem install prawn -v0.6.3
Installing Rails

You should install the Rails framework.

[[email protected] rubygems-1.3.7]# gem install rails -v2.3.5

Do not update the gems. You should also check if rake is version 0.8.7 otherwise do a gem uninstall rake and a gem install rake -v 0.8.7

Installing MySQL

Some distributions come with MySQL 5.0.77-4.el5_6.6 so first lets remove it

[[email protected] rubygems-1.3.7]# yum remove mysql mysql-server mysql-devel

Now install the MySQL database

[[email protected] rubygems-1.3.7]# yum install mysql mysql-server mysql-devel

You should see the following message Complete!

Now lets start MySQL and secure the "root" user

[[email protected] rubygems-1.3.7]# sudo /etc/init.d/mysqld start
While the MySQL server is being started you will be presented with instructions to create user accounts
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h i-3781-9521-VM password 'new-password'


Test your password using the following command

[[email protected] rubygems-1.3.7]# mysql -uroot -p<your password>

Now install support for rails

[[email protected] rubygems-1.3.7]# gem install mysql -- --with-mysql-config=/usr/lib64/mysql/mysql_config

Thats quick. Lets check to see if its properly installed. Start the interactive ruby shell

[[email protected] rubygems-1.3.7]# irb
irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> require 'mysql'
=> true
irb(main):003:0>

Now its time to install a server to serve your rails application over the web. Lets install Phusion's passenger

Phusion's Passenger

There are other servers like Thin, Mongrel etc however Phusion is the preferred because it doesn't replicate the http request handling functionality of apache/nginx/lighttpd but instead latches on to apache and nginx as a module.

We'll now need to install the Passenger server to serve Fedena to all http requests comming in through Nginx.

[[email protected] ruby-1.8.7-p352]# gem install passenger
[[email protected] ruby-1.8.7-p352]# passenger-install-nginx-module

Its very likely that you see the following messages

Checking for required software...

 * GNU C++ compiler... not found
 * The 'make' tool... found at /usr/bin/make
 * A download tool like 'wget' or 'curl'... found at /usr/bin/wget
 * Ruby development headers... found
 * OpenSSL support for Ruby... not found
 * RubyGems... found
 * Rake... found at /usr/local/bin/rake
 * rack... found
 * Curl development headers with SSL support... not found
 * OpenSSL development headers... found
 * Zlib development headers... not found

Some required software is not installed.
But don't worry, this installer will tell you how to install them.

Press Enter to continue, or Ctrl-C to abort.

Installation instructions for required software

 * To install GNU C++ compiler:
   Please run yum install gcc-c++ as root.

 * To install OpenSSL support for Ruby:
   Please (re)install Ruby with OpenSSL support by downloading it from http://www.ruby-lang.org/.

 * To install Curl development headers with SSL support:
   Please run yum install curl-devel as root.

 * To install Zlib development headers:
   Please run yum install zlib-devel as root.

If the aforementioned instructions didn't solve your problem, then please take
a look at the Users Guide:

At this point install the missing software and install ruby again with openssl support Lets first install zlib support

[[email protected] ~]# cd ~/ruby-1.8.6
[[email protected] ruby-1.8.7-p352]# ruby extconf.rb --with-zlib-include=/usr/include --with-zlib-lib=/usr/lib
[[email protected] ruby-1.8.7-p352]# make
[[email protected] ruby-1.8.7-p352]# sudo make install

Lets install openssl

[[email protected] ruby-1.8.7-p352]# cd ~/ruby-1.8.6/ext/openssl
[[email protected] openssl]# ruby extconf.rb
[[email protected] ruby-1.8.7-p352]# make
[[email protected] ruby-1.8.7-p352]# sudo make install

Install the passenger nginx module. If all is well you should see the following message

[[email protected] ruby-1.8.7-p352]# passenger-install-nginx-module

  http {
      ...
      passenger_root /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.8;
      passenger_ruby /usr/local/bin/ruby;
      ...
  }


After you (re)start Nginx, you are ready to deploy any number of Ruby on Rails
applications on Nginx.

Suppose you have a Ruby on Rails application in /somewhere. Add a server block
to your Nginx configuration file, set its root to /somewhere/public, and set
'passenger_enabled on', like this:

   server {
      listen 80;
      server_name www.yourhost.com;
      root /somewhere/public;   # <--- be sure to point to 'public'!
      passenger_enabled on;
   }

And that's it! You may also want to check the Users Guide for security and
optimization tips and other useful information:

  /usr/local/lib/ruby/gems/1.8/gems/passenger-3.0.8/doc/Users guide Nginx.html
Download and setup Fedena

Download fedena from Github. The --no-check-certificate flag allows wget to connect without checking the certificate

[[email protected] ~]# wget --no-check-certificate https://github.com/projectfedena/projectfedena_v2.0/tarball/master

A file "master" will be downloaded. Now rename the file as shown below

[[email protected] ~]# cp master projectfedena-projectfedena_v2.0-a213125.tar.gz
[[email protected] ~]# rm master
[[email protected] ~]# chmod 777 projectfedena-projectfedena_v2.0-a213125.tar.gz
[[email protected] ~]# tar -xvf projectfedena-projectfedena_v2.0-a213125.tar.gz

The contents of the file will be extracted into a directory

Make changes to the database configuration file

Recollect the password you provided when you installed MySQL' Open the file database.yml in the config folder of the fedena source. Change the following details: database: fedena - The name of the database you want to use for fedena username: root - Mysql username for fedena password: mypass - The password for the above mysql user

Set up Fedena databases

From the Fedena source directory in terminal run,

 "rake db:create"

followed by,

"rake db:migrate"
Install rest of the gems
"gem install declarative_authorization -v 0.5.1"
"gem install searchlogic -v 2.4.27"
"gem install i18n -v 0.4.2"
Configure the virtual hosts
[[email protected] ~]# nano /etc/httpd/conf/httpd.conf
<VirtualHost *:80>
     ServerAdmin [email protected]
     DocumentRoot /projectfedena-projectfedena_v2.0-a213125
     ServerName	www.domain.ext
</VirtualHost>

Restart the nginx server.

sudo /etc/init.d/httpd reload

Thats all there is to it. Visit the URL and you should see the fedena login page.

Was this answer helpful?

 Print this Article

Also Read

How to resize volumes with LVM?

Quick tips: To see the details of logical volume group use: vgdisplay To see the details of...

Set a Cron Job in Linux

There are occasions when you want to create a schedule tasks on your server. Suppose you want to...

KVM create and restore a full backup (Disk Image)

Making a backupBoot the system rescue cd ISO and follow the directions until you get to a...

How to Cache or copy a website?

Full website contents can be copied with wget command with below options :wget \--recursive...

How to Configure Centos 6 firewall (iptables)?

Introduction CentOS 6 uses iptables as system firewall.We configure iptables in our default...