Tuesday, November 26, 2013

Installing Ruby on Rail on Centos 6 (64 bit) Virtual Machine

Ruby on Rails


Prerequisites

  • Ruby language version 1.9.3 or newer
  • The RubyGems packaging system
  • A working installation of the SQLite3 Database

  • On my development environment, I used centos 6 64 bit minimal (no GUI) operating system to run ruby on rails. I installed it on Oracle Virtualbox.

    Step 1: Install the Ruby
    Check the ruby version.
    [root@centosAshley02 ~]# ruby -v
    -bash: ruby: command not found
    
    No found command means we have to intall ruby.
    Install the wget command to download source files
    [root@centosAshley02 ~]# yum install wget
    
    Download rpm and update the system
    [root@centosAshley02 ~]# cd /tmp/
    [root@centosAshley02 ~]# wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
    [root@centosAshley02 ~]# rpm -Uvh epel-release-6-8.noarch.rpm
    [root@centosAshley02 ~]# yum -y update
    
    [root@centosAshley02 ~]# yum -y groupinstall "Development Tools"
    [root@centosAshley02 ~]# yum -y install libxslt-devel libyaml-devel libxml2-devel gdbm-devel libffi-devel zlib-devel openssl-devel libyaml-devel readline-devel curl-devel openssl-devel pcre-devel git memcached-devel valgrind-devel mysql-devel ImageMagick-devel ImageMagick
     
    
    Get the latest ruby version using wget command
    [root@centosAshley02 ~]# cd /usr/src/
    [root@centosAshley02 ~]# wget ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p353.tar.gz
    [root@centosAshley02 ~]# tar zxvf ruby-2.0.0-p353.tar.gz
    [root@centosAshley02 ~]# cd ruby-2.0.0-p353
    [root@centosAshley02 ~]# ./configure
    [root@centosAshley02 ~]# make
    [root@centosAshley02 ~]# make install
    
    Show the ruby version.
    [root@centosAshley02 ~]# ruby -v
    ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-linux]
    
    Step 2: Install the Rubygems
    [root@centosAshley02 ~]# cd /usr/src/
    [root@centosAshley02 src]# wget http://production.cf.rubygems.org/rubygems/rubygems-2.1.7.tgz
    [root@centosAshley02 src]# tar zxvf rubygems-2.1.7.tgz
    [root@centosAshley02 src]# cd rubygems-2.1.7
    [root@centosAshley02 rubygems-2.1.7]# /usr/local/bin/ruby setup.rb
    
    Check the rubygem installation, the back to parent directory
    [root@centosAshley02 rubygems-2.1.7]# gem -v
    2.1.7
    [root@centosAshley02 rubygems-2.1.7]# cd
    
    Step:3 Install Sqlite
    If you don't have curl then execute the following
    [root@centosAshley02 ~]# yum install curl
    
    Install rvm
    curl -L get.rvm.io | bash -s stable
    
    Source the file rvm.sh
    source /etc/profile.d/rvm.sh
    
    for me to check, I type.
    [root@centosAshley02 ~]# rvm requirements
    Checking requirements for centos.
    Requirements installation successful.
    
    Step 4: Sqlite
    [root@centosAshley02 ~]# cd /opt/
    [root@centosAshley02 opt]# wget http://www.sqlite.org/2013/sqlite-autoconf-3080100.tar.gz
    [root@centosAshley02 opt]# tar xvzf sqlite-autoconf-3080100.tar.gz
    [root@centosAshley02 opt]# ln -s /opt/sqlite-autoconf-3080100/ /opt/sqlite3
    [root@centosAshley02 opt]# cd sqlite3/
    [root@centosAshley02 opt]# ./configure --prefix=/opt/sqlite3
    
    Configure the .bashrc
    [root@centosAshley02 ~]# vi .bashrc
    
    add on the .bashrc LD_LIBRARY_PATH=/usr/local/lib64 then source and test the varibale
    [root@centosAshley02 ~]# source .bashrc
    [root@centosAshley02 ~]# echo $LD_LIBRARY_PATH
    /usr/local/lib64
    [root@centosAshley02 ~]# export LD_LIBRARY_PATH=/usr/local/lib64:$LD_LIBRARY_PATH
    
    Then make and make install
    [root@centosAshley02 ~]# cd /opt/sqlite3
    [root@centosAshley02 sqlite3]# make
    [root@centosAshley02 sqlite3]# make install
    
    Test the sqlite,
    [root@centosAshley02 ~]# mkdir -p /usr/local/sqlite/var
    [root@centosAshley02 ~]# sqlite3 /usr/local/sqlite/var/testdb
    SQLite version 3.6.20
    Enter ".help" for instructions
    Enter SQL statements terminated with a ";"
    sqlite>
    

    Then .exit, for more info type .help
    Step 5: Install the rails
    This may take time. Please be patient.
    [root@centosAshley02 ~]# gem install rails
    
    Check the gems installed.
    [root@centosAshley02 ~]# gem list
    
    *** LOCAL GEMS ***
    
    actionmailer (4.0.1)
    actionpack (4.0.1)
    activemodel (4.0.1)
    activerecord (4.0.1)
    activerecord-deprecated_finders (1.0.3)
    activesupport (4.0.1)
    arel (4.0.1)
    atomic (1.1.14)
    bigdecimal (1.2.0)
    builder (3.1.4)
    bundler (1.3.5)
    erubis (2.7.0)
    hike (1.2.3)
    i18n (0.6.5)
    io-console (0.4.2)
    json (1.7.7)
    mail (2.5.4)
    mime-types (1.25.1)
    minitest (4.3.2)
    multi_json (1.8.2)
    polyglot (0.3.3)
    psych (2.0.0)
    rack (1.5.2)
    rack-test (0.6.2)
    rails (4.0.1)
    railties (4.0.1)
    rake (0.9.6)
    rdoc (4.0.0)
    sprockets (2.10.1)
    sprockets-rails (2.0.1)
    test-unit (2.0.0.0)
    thor (0.18.1)
    thread_safe (0.1.3)
    tilt (1.4.1)
    treetop (1.4.15)
    tzinfo (0.3.38)
    
    Install the sqlite-ruby
    [root@centosAshley02 ~]# yum install sqlite-devel
    [root@centosAshley02 ~]# gem install sqlite3
    
    check the gem list again and find the sqlite
    [root@centosAshley02 ~]# gem list
    
    *** LOCAL GEMS ***
    
    actionmailer (4.0.1)
    actionpack (4.0.1)
    activemodel (4.0.1)
    activerecord (4.0.1)
    activerecord-deprecated_finders (1.0.3)
    activesupport (4.0.1)
    arel (4.0.1)
    atomic (1.1.14)
    bigdecimal (1.2.0)
    builder (3.1.4)
    bundler (1.3.5)
    erubis (2.7.0)
    hike (1.2.3)
    i18n (0.6.5)
    io-console (0.4.2)
    json (1.7.7)
    mail (2.5.4)
    mime-types (1.25.1)
    minitest (4.3.2)
    multi_json (1.8.2)
    polyglot (0.3.3)
    psych (2.0.0)
    rack (1.5.2)
    rack-test (0.6.2)
    rails (4.0.1)
    railties (4.0.1)
    rake (0.9.6)
    rdoc (4.0.0)
    sprockets (2.10.1)
    sprockets-rails (2.0.1)
    sqlite3 (1.3.8)
    sqlite3-ruby (1.3.3)
    test-unit (2.0.0.0)
    thor (0.18.1)
    thread_safe (0.1.3)
    tilt (1.4.1)
    treetop (1.4.15)
    tzinfo (0.3.38)
    
    Almost done, We have to install execjs for javascript runtime and rubyracer
    gem install debugger-ruby_core_source -v 1.2.2
    sources: http://guides.rubyonrails.org/getting_started.html
    https://gist.github.com/fabrizioc1/1083087
    http://sqlrelay.sourceforge.net/sqlrelay/gettingstarted/sqlite.html https://github.com/cldwalker/debugger/issues/12

    Monday, November 25, 2013

    Configuring Network in Centos 6.4 Virtual Box with Screen Shots

    This is a guide on configuring network in Centos Virtual Box with screenshots

    Requirements

    1. Virtual Box 
    2. Centos 6.3 or 6.4 (I used 6.4 )

    Step 1 : Configure Virtual Box Network Settings

    There are different modes or ways you can configure Virtual box network settings.
    1. Not Attached
    2. NAT
    3. Bridged Adapter
    4. Internal Network
    5. Host-Only Adapter
    6. Generic Driver
    7. You can find more details about the different modes here.
    I will be using the Bridged Adapter mode for this guide. It is faster as it treat the VM as an individual host within the network.
    Open Virtual Box and right click on your CentOS VM, and click on “Settings“.
    Go to the "Network tab" then changed the "Attached to" field to "Bridged Adapter". Choose "Name" to your network interface. Then click "ok" to save the configuration. Click "Show" to run the machine.
     

    Step 2: Configure CentOS network settings

    Method 1: Dynamic IP

    We can configure the network by using Dynamic IP address which are assigned automatically by the DHCP server. This is the simplest way to configure your network.

    NOTE: You will have a line that starts with HWADDR in the your config file, do not change or modify that line. In your terminal, type the following:
    vi /etc/sysconfig/network-scripts/ifcfg-eth0
    Now, add/modify the file as follows (DO NOT CHANGE the HWADDR line your config file):
    DEVICE=eth0
    HWADDR=08:00:27:36:3F:37
    TYPE=Ethernet
    UUID=1e4ee4d1-e438-4db2-9cb5-45e7a488be88
    ONBOOT=yes
    NM_CONTROLLED=yes
    BOOTPROTO=dhcp
    
    Now, save the file by pressing “ESC” and typing :wq and hit ENTER.
    To view your network config file. type the following in the terminal:
    [root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
    DEVICE=eth0
    HWADDR=08:00:27:36:3F:37
    TYPE=Ethernet
    UUID=1e4ee4d1-e438-4db2-9cb5-45e7a488be88
    ONBOOT=yes
    NM_CONTROLLED=yes
    BOOTPROTO=dhcp
    
    Now, you will have to restart your network. You can do so by typing the following in the terminal:
    service network restart
    Your result must be
    [root@localhost ~]# service network restart
    Shutting down interface eth0:                              [  OK  ]
    Shutting down loopback interface:                          [  OK  ]
    Bringing up loopback interface:                            [  OK  ]
    Bringing up interface eth0:
    Determining IP information for eth0... done.
                                                               [  OK  ]
    
    To view your IP address, type the following in your terminal:
    ifconfig eth0
    You can see your IP Address of the interface eth0 next to the field “inet addr:” as shown below:
    Now, if you have internet access, then you can check if you are able to ping any website. And you should be able to get the reply. For example, in your terminal type:
     
    ping google.com
    
     
    You can press CTRL+ C to stop the ping command.
    So, Hurray! you have successfully setup up your network in your CentOS Virtual Box.

    Method 2: Static IP

    We can also assign the network information manually by assigning the IP Address, NETMASK , GATEWAY in the network interface config file.
    NOTE: You will have a line that starts with HWADDR in your config file, do not change or modify that line.

    Step 1:

    In you terminal, type:
    vi  /etc/sysconfig/network-scripts/ifcfg-eth0
    
    Now, edit/merge the file to the following
    DEVICE=eth0
    HWADDR=08:00:27:EB:C1:68
    TYPE=Ethernet
    UUID=38341514-767c-4546-9154-859a7b495642
    ONBOOT=yes
    NM_CONTROLLED=no
    BOOTPROTO=static
    IPADDR=172.16.2.105
    GATEWAY=172.16.0.1
    
    Now, press ESC and type :wq and hit ENTER to save and exit the configuration file.
    cat /etc/sysconfig/network-scripts/ifcfg-eth0
    
     

    Step 2: Change Host name: 

    To change host name , you have to edit the config file /etc/sysconfig/network.
    vi /etc/sysconfig/network
    
    Now, you will see a file such as the one shown below:

    To change the hostname , you can change the highlighted to any thing you want. Press ‘i‘ or INSERT to edit the file. After making necessary changes, you can save the file by pressing ESC followed by :wq and hit ENTER.
    Now, restart to make necessary changes. You can reboot by typing the following in the command line:
    reboot
    After reboot, login and check your hostname by typing the following in the terminal / command line :
    hostname
    Step 3: Assign DNS Server IP

    To manually assign primary and secondary DNS Server IP addresses, in your terminal type:
    vi /etc/resolv.conf
    Now, edit this file to the following:
    ; generated by /sbin/dhclient-script
    nameserver 8.8.8.8
    nameserver 8.8.4.4
    
    Now, press ESC and type :wq and hit ENTER to save and exit the configuration file.
    Now, if you want you can make sure you have entered and saved the correct configuration(It is a good practice to double check :D ). To view your dns config file, in your terminal type:
    cat  /etc/resolv.conf

    Step 4: Restart network:

    Finally, all you have to do is to restart your network service. To so so, type the following in the terminal:
     service network restart
    
    [root@centosAshley02 ~]# service network restart
    Shutting down interface eth0:                              [  OK  ]
    Shutting down loopback interface:                          [  OK  ]
    Bringing up loopback interface:                            [  OK  ]
    Bringing up interface eth0:                                [  OK  ]
    
    Now, you can check your Current IP configuration, by typing the following in the terminal:
    Now, if you have internet access, then you can check if you are able to ping any website. And you should be able to get the reply. For example, In your terminal type:
    ping imbaprogramming.blogspot.com
    

    You can press CTRL+ C to stop the ping command.
    So, Hurray! you have successfully setup up your network manually in your CentOS Virtual Box.
     
    source : http://extr3metech.wordpress.com/2013/05/23/configuring-network-in-centos-6-3-virtual-box-screenshots/

    Monday, November 18, 2013

    Asterisk RealTime MeetMe

    1. Installing and Configuring ODBC


    The ODBC connector is a database abstraction layer that makes it possible for Asterisk to communicate with a wide range of databases without requiring the developers to create a separate database connector for every database Asterisk wants to support.
    First Install the ODBC LINUX

    yum install -y unixODBC unixODBC-devel libtool-ltdl libtool-ltdl-devel
    unixODBC-devel package because it is used by Asterisk to create the ODBC modules Next,

     Configure the PostgreSQL ODBC driver  
    [PostgreSQL]
    Description             = ODBC for PostgreSQL
    Driver          = /usr/lib/psqlodbc.so
    Setup           = /usr/lib/libodbcpsqlS.so
    Driver64                = /usr/lib64/psqlodbc.so
    Setup64         = /usr/lib64/libodbcpsqlS.so
    FileUsage               = 1
    UsageCount              = 5
    
    To test execute
    # odbcinst -q -d 
    [PostgreSQL]
    

    Configuring ODBC for MySQL

    On CENTOS
    [MySQL]
    Description = ODBC for MySQL
    Driver = /usr/lib/libmyodbc3.so
    Setup = /usr/lib/libodbcmyS.so
    FileUsage = 1
    
    On UBUNTU
    [MySQL]
    Description = ODBC for MySQL
    Driver = /usr/lib/odbc/libmyodbc.so
    Setup = /usr/lib/odbc/libodbcmyS.so
    FileUsage = 1
    
    NOTE: On 64-bit systems, you will need to change the path of the libraries from /usr/lib/ to /usr/lib64/ in order to access the correct library files.
    On my 64 bit CENTOS
     
    [MySQL]
    Description             = ODBC for MySQL
    Driver          = /usr/lib/libmyodbc5.so
    Setup           = /usr/lib/libodbcmyS.so
    Driver64                = /usr/lib64/libmyodbc5.so
    Setup64         = /usr/lib64/libodbcmyS.so
    FileUsage               = 1
    UsageCount              = 5
    
    Verify the driver
    # odbcinst -q -d
    [PostgreSQL]
    [MySQL]
    
    Next, configure the /etc/odbc.ini file, which is used to create an identifier that Asterisk will use to reference this configuration.
    [ConfConnection]
    Description             = MySQL connection to 'asterisk' database
    Driver          = MySQL
    Database                = asteriskdb
    Server          = localhost
    UserName                = root
    Password                = allysamae
    Port            = 3306
    Socket          = /var/lib/mysql/mysql.sock
    
    NOTE: On Ubuntu 10.10, the socket location is /var/run/mysqld/mysqld.sock.

    Validating the ODBC Connector
     
    Now, verify that you can connect to your database using the isql application. echo the select 1 statement and pipe it into isql, which will then connect using the asterisk-connector section you added to /etc/odbc.ini. You should get the following output (or at least something similar; we’re looking for a result of 1 rows fetched):
    # echo "select 1" | isql -v ConfConnection
    +---------------------------------------+
    | Connected!                            |
    |                                       |
    | sql-statement                         |
    | help [tablename]                      |
    | quit                                  |
    |                                       |
    +---------------------------------------+
    SQL> select 1
    +---------------------+
    | 1                   |
    +---------------------+
    | 1                   |
    +---------------------+
    SQLRowCount returns 1
    1 rows fetched
    
     
    Recompile Asterisk

    With unixODBC installed, configured, and verified to work, you need to recompile Asterisk so that the ODBC modules are created and installed. Change back to your Asterisk source directory and run the ./configure script so it knows you have installed unixODBC:
    # cd /usr/src/asterisk*
    # ./configure
    # make menuselect
    # make install
    
    NOTE: You will want to run make menuselect to verify that the ODBC-related modules are enabled. These include cdr_odbc, cdr_adaptive_odbc, func_odbc, func_realtime, pbx_realtime, res_config_odbc, and res_odbc. For voicemail stored in an ODBC database, be sure to select ODBC_STORAGE from the Voicemail Build Options menu. You can verify that the modules exist in the /usr/lib/asterisk/modules/ directory.

    Configuring res_odbc to Allow Asterisk to Connect Through ODBC

    Asterisk ODBC connections are configured in the res_odbc.conf file located in /etc/asterisk. The res_odbc.conf file sets the parameters that various Asterisk modules will use to connect to the database.
    NOTE: The pooling and limit options are quite useful for MS SQL and Sybase databases. These permit you to establish multiple connections (up to limit connections) to a database while ensuring that each connection has only one statement executing at once (this is due to a limitation in the protocol used by these database servers).
    ; The context name is what will be used in other configuration files, such
    ; as extconfig.conf and func_odbc.conf, to reference this connection.
    [asteriskdb]
    ;
    ; Permit disabling sections without needing to comment them out.
    ; If not specified, it is assumed the section is enabled.
    enabled => yes
    ;
    ; This value should match an entry in /etc/odbc.ini
    ; (or /usr/local/etc/odbc.ini, on FreeBSD and similar systems).
    dsn => ConfConnection
    ;
    ; Username for connecting to the database.  The user defaults to the context name if unspecified.
    username => root
    ;
    ; Password for authenticating the user to the database.  The default
    ; password is blank.
    password => mypassword
    ;
    ; Build a connection at startup?
    pre-connect => yes
    
    The dsn option points at the database connection you configured in /etc/odbc.ini, and the pre-connect option tells Asterisk to open up and maintain a connection to the database when loading the res_odbc.so module. This lowers some of the overhead that would come from repeatedly setting up and tearing down the connection to the database.
    Once you’ve configured res_odbc.conf, start Asterisk and verify the database connection with the odbc show CLI command:
    *CLI> odbc show asteriskdb
    
    ODBC DSN Settings
    -----------------
    
      Name:   asteriskdb
      DSN:    ConfConnection
        Last connection attempt: 2013-11-19 09:29:44
      Pooled: No
      Connected: Yes
    
    

    grant all privileges on *.* to root@172.16.2.133 identified by '!green0909!';

    sources: http://www.asteriskdocs.org/en/2nd_Edition/asterisk-book-html-chunk/installing_configuring_odbc.html

    Sunday, November 17, 2013

    Simple Conference Call in Asterisk 11.4.0

    A conference call is a telephone call in which the calling party wishes to have more than one called party listen in to the audio portion of the call. The conference calls may be designed to allow the called party to participate during the call, or the call may be set up so that the called party merely listens into the call and cannot speak. It is sometimes called ATC (Audio Tele-Conference).

    1. First step is to register 3 sip phones. 
     
    [1001]
    user=1001
    secret=123456
    type=friend
    host=dynamic
    nat=yes
    context=confroom
    [1002]
    user=1002
    secret=123456
    type=friend
    host=dynamic
    nat=yes
    context=confroom
    [1003]
    user=1003
    secret=123456
    type=friend
    host=dynamic
    nat=yes
    context=confroom
    2. Make sure there is Asterisk Application app_meeme. To check, go to the asterisk source file

    cd /usr/src/asterisk*
    make menuselect
    
    make sure app_meetme is [*] checked. If not select it and reinstall. Then restart the asterisk.
    make install
    service asterisk restart
    3. In /etc/asterisk/meetme.conf
     
    [rooms]
    ;
    ; Usage is conf => confno[,pin][,adminpin]
    ;
    ; Note that once a participant has called the conference, a change to the pin
    ; number done in this file will not take effect until there are no more users
    ; in the conference and it goes away.  When it is created again, it will have
    ; the new pin number.
    ;
    ;conf => 1234
    ;conf => 2345,9938
    conf => 500
    conf => 500
    
    4. Then go to the /etc/asterisk/extension.conf to set the dialplan for the conference calls.
    [confroom]
    exten => 999,1,Answer()
    exten => 999,n,Meetme(500)
    exten => 999,n,Hangup()
    
    Then test it. Dial 999 to every sip phones registered on the confroom context.

    Asterisk 11.4.0 Call File

    Call File are like shell script for Asterisk. A user or application writes a call file into /var/spool/asterisk/outgoing/ where Asterisk processes it immediately.

    NOTE: A mv (move) is an atomic operation (an operation which does not take effect until it is 100% complete) and as such is ideally suited for .call files. With cp (copy), the file is copied line by line, which could lead to Asterisk processing an incomplete file.

    Let's demonstrate the .call file principle with an example. Assume that we have a SIP phone registered with the number 2000 in Asterisk. In addition, we have the following extension in the dialplan:
    [call-file-test]
    exten => 10,1,Answer()
    exten => 10,n,Wait(1)
    exten => 10,n,Playback(hello-world)
    exten => 10,n,Wait(1)
    exten => 10,n,Hangup()
    
    We create a call file called a-test.call in /tmp/ with the following content:
    Channel: SIP/2000
    MaxRetries: 2
    RetryTime: 60
    WaitTime: 30
    Context: call-file-test
    Extension: 10
    
    Now we move this file with mv /tmp/a-test.call /var/spool/asterisk/outgoing/
    root@molokai:~>mv /tmp/a-test.call /var/spool/asterisk/outgoing/
    The following happens:
    • Asterisk polls the /var/spool/asterisk/outgoing/ for new call files and processes any it finds. 
    • Asterisk opens a connection to device SIP/2000. If the device is in use or not answered, Asterisk tries two more times (see MaxRetries). 
    • If someone answers SIP/2000, Asterisk begins processing extension 10 in the context [call-file-test]. In this case, Asterisk plays hello-world to the answering party.

    Parameters

    These parameters may be used in call files:
    Channel: <channel>
    The channel upon which to initiate the call. Uses the same syntax as the Dial() command (see Section B.27, “Dial()”).
    Callerid: <callerid>
    The caller ID to be used for the call.
    WaitTime: <number>
    Number of seconds the system waits for the call to be answered. If not specified, defaults to 45 seconds.
    MaxRetries: <number>
    Maximum number of dial retries (if an attempt fails because the device is busy or not reachable). If not specified, defaults to 0 (only one attempt is made).
    RetryTime: <number>
    Number of seconds to wait until the next dial attempt. If not specified, defaults to 300 seconds.
    Account: <account>
    The account code for the CDR.
    Context: <context>
    The destination context.
    Extension: <exten>
    The destination extension, in which dialplan execution begins if the device is answered.
    Priority: <priority>
    The destination priority. If not specified, defaults to 1.
    Setvar: <var=value>
    Setvar: lets you set one or more channel variables.
    Archive: <yes|no>
    By default, call files are deleted immediately upon execution. If Archive: yes is set, they are copied into/var/spool/asterisk/outgoing_done/ instead. Asterisk adds a line to the call file which describes the result:
    Status: <Expired|Completed|Failed>

    Wednesday, November 13, 2013

    Installing asterisk 11.4.0 to Centos 6.4 (64 bit)

    1. Initial Set Up

    You MUST run all of these commands as the root user!

    2. Update the System

    yum -y update
    yum groupinstall core
    yum groupinstall base
    

    3. Install Required Dependencies

    yum install gcc gcc-c++ bison mysql-devel mysql-server php php-mysql 
    php-pear php-mbstring tftp-server httpd make ncurses-devel libtermcap-devel sendmail sendmail-cf 
    caching-nameserver sox newt-devel libxml2-devel libtiff-devel audiofile-devel gtk2-devel subversion 
    kernel-devel git subversion kernel-devel php-process sqlite-devel

    4. Disabling SELINUX

    sed -i s/SELINUX=enforcing/SELINUX=disabled/g /etc/selinux/config

    5. Install PearDB

    You must have php with php-pear. You can refer on this link
    pear install db
    NOTE: You may receive a warning:
    WARNING: "pear/DB" is deprecated in favor of "pear/MDB2" At this time it is safe to ignore that message

    5. Reboot Server

    reboot

    6. Download the Source Tarballs

    wget http://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-current.tar.gz
    wget http://downloads.asterisk.org/pub/telephony/libpri/libpri-1.4-current.tar.gz
    git clone https://github.com/spditner/asterisk-11.4.0
    

    7. Extract the Files

    tar zxvf dahdi-linux-complete*
    tar zxvf libpri*
    unzip asterisk*
    

    8. Install DAHDI and libpri

    NOTE: For the next set of commands it is important to follow the proper order: DAHDI first, then libpri, then Asterisk.
    Install DAHDI
    cd /usr/src/dahdi-linux-complete*
    make && make install && make config
    Install libpri.
    cd /usr/src/libpri*
    make && make install

    9. Install the Asterisk

    Change to the Asterisk directory.
    cd /usr/src/asterisk*
    Use this command if you are installing Asterisk on 64bit CentOS.
    ./configure --libdir=/usr/lib64 && make menuselect && make && make install
    OPTIONAL: If you ran into errors you will want to clean the install directory before recompiling.
    make clean && make distclean
    Once you have an error-free install, copy the sample files from the configs subdirectory into /etc/asterisk.
    make samples
    Then add the Asterisk start script to the /etc/init.d/ directory
    make config

    10. Start and Connect to the Asterisk

    Start DAHDI.
    service dahdi start
    Start Asterisk.
    service asterisk start
    Connect to the Asterisk CLI.
    asterisk -rvvv
    sources: http://blogs.digium.com/2012/11/05/how-to-install-asterisk-11-on-centos-6/ http://wiki.freepbx.org/display/HTGS/Installing+FreePBX+on+Centos+6.3