How To Install Ruby on Rails with rbenv on CentOS 7 or RHEL 7

1. Introduction

This article helps you install and configure Ruby on Rails on CentOS 7. By following some simple steps you can start riding on rails. Please feel free to let us know if you got struck anywhere, we will help you fix it.

2. Prerequisites

Here, We assume that you are having a CentOS 7 installed server with root access. Before continuing the installation we need to install LAMP/LEMP. You can follow the link to install LAMP and then proceed with the installation.

3. Installation

First of all, let me provide you a very short description about Ruby on Rails. Ruby is a programming language and while rails is just a Web application frame work which works on the principle (Model-View-Controller) MVC. Ruby on Rails is nothing but simply a web application framework written in Ruby. You can check there official link to know more.

3.1. Installation of Rbenv

Rbenv is a ruby version management tool. We will use this to install and manage our Ruby installation. So let’s start the installation of rbenv.

Installing the dependencies of Rbenv and Ruby. Use the following commands to install the dependencies.

# yum install -y git-core zlib zlib-devel gcc-c++ patch readline readline-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison curl sqlite-devel

Now we are going to edit the bash profile file of the user who is going to use ruby. So make sure to take a backup of the .bash_profile at first . Then you may execute the following commands as the same user.

# cd
# git clone git:// .rbenv
# echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
# echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
# source ~/.bash_profile
# git clone git:// ~/.rbenv/plugins/ruby-build
# echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bash_profile
# source ~/.bash_profile

Your bash profile look like the screen shot given below.

Thus you have installed rbenv. After completing this step, please open a new terminal to start using rbenv otherwise it will show “rbenv not found error”. Now we are ready to install Ruby.

3.2 Installation of Ruby

Before starting the installation, Check which version of ruby you want to install. Here, We are installing Ruby 2.2.1.
You may execute the commands below to install Ruby.

# rbenv install -v 2.2.1

The next step is to sets the default version of Ruby that all of your shells will use. If you want to install and use a different version, simply run the rbenv commands with a different version number.

# rbenv global 2.2.1

You can verify the installation using the command below. It will show you the version and details of the installation.

[root@hostname-centos7 ~]# ruby -v
ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-linux]

Most of us do not want the documentation of each gems we install. If you would like to disable this, you may execute the command as below.

# echo "gem: --no-document" > ~/.gemrc

Now, Install the bundler gem which is used to manage your application dependencies using the following commands.

# gem install bundgem install bundlerler

Thus the Ruby is installed. Now we can move on to the installation of Rails.

3.3 Installation of Rails

As the same user who installed Ruby, execute the command below to install Rails. Here, We are installing Rails 4.2.0 version.

# gem install rails -v 4.2.0

We need to run rbenv rehash command whenever we use gem. to install/uninstall. The rbenv normally runs rbenv rehash automatically when you install/uninstall using gem. But to make sure, you may execute following command every time you use gem command.

# rbenv rehash

To check the version of Rails, you can execute the command below.

[root@hostname-centos7 ~]# rails -v
Rails 4.2.0

Thus, We have completed the installation of Ruby on Rails.

4. Apache Configuration (Configuring Ruby to run on Port 80)

Normally, The Ruby on Rails application run on port 3000. So, we need to specify the port all the time we access any of the ruby application. To avoid this, We made here a very simple proxy setup in apache configuration. The configuration is as follows.

ProxyPreserveHost On
ProxyPass / http://yourip:3000/
ProxyPassReverse / http://yourip:3000/

In the above configuration, you need to specify your IP address instead “yourip” and save the file. After that, you may just restart the apache to reflect the changes.

# systemctl restart httpd

Thus the proxy setup via apache configuration is completed. Now we can test its working by creating an application.

5. Create a Test Application

To make sure that the Ruby on Rails installation completed successfully, We can create a test application by following the steps below.

Create an application in your home directory as follows:

# cd ~
# rails new testapp

Now, move on to the application directory:

# cd testapp

Then, create a sqlite3 database:

# rake db:create

Thus the configuration has been completed. Now, you can start your application by following the commands. Look at the screenshot below.

# rails server --binding=server_public_IP

If it is running properly, You will get a welcome aboard page by visiting the URL below.


You will see a welcome aboard page. It is the smoke test for a new Rails application. it makes sure that you have your software configured correctly enough to serve a page.


6. Conclusion

Thus you are ready to start developing your new Ruby on Rails application. Enjoy !!

How to install Ioncube Loader on CentOS 7 or RHEL 7 or Debian 8

1. Introduction

Ioncube loader is a PHP module or extension which makes PHP files or websites more secure. It also helps in speeding up webpages. It encrypts PHP language and used for many other PHP applications.

2. Requirements

Before installing ioncube loader your server must have php installed on both CentOs 7 and Debian 8.

3. Download and extract Ioncube Loader

I will be downloading the 64-bit version of ioncube loader as my system is a 64-bit server.

# cd /usrlocal/src
# wget
# tar xfz ioncube_loaders_lin_x86-64.tar.gz

4. Configure ioncube loader

To configure ioncube we need to know which version of PHP is running.

Check the PHP version using the command:

# php -v
PHP 5.4.45 (cli) (built: Sep 30 2015 15:42:23) 
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies

Now check PHP extension directory using the following command

# php -i | grep extension_dir
extension_dir => /usr/lib64/php/modules => /usr/lib64/php/modules

Note: not all versions of PHP use the same location. It may be different for other servers. Use exact location that you get.

Open the ioncube folder and copy the ioncube loader file that matches your PHP version.

# ls /usr/local/src/ioncube
# cp /usr/local/src/ioncube/ /usr/lib64/php/modules

The next configuration step is a bit different for Centos and Debian/Ubuntu. We will have to add a line:

zend_extension = /usr/lib64/php/modules/

For CentOs 7:

Open the file /etc/php.ini and add the following line:

zend_extension = /usr/lib64/php/modules/

Now, restart the apache service.

# service httpd restart

For Debian 8:

In Debian there are separate php.ini files for PHP CLI, CGI, Apache2 and FPM mode such as:


Add zend_extension to the files and save:

zend_extension = /usr/lib/php5/20131226/

Now, restart apache service.

# service apache2 restart

5. Check result

In centos7

# php -v
PHP 5.4.45 (cli) (built: Sep 30 2015 15:42:23) 
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
    with the ionCube PHP Loader (enabled) + Intrusion Protection from (unconfigured) v5.0.19, Copyright (c) 2002-2015, by ionCube Ltd.

In Debian 8

# php -v
PHP 5.6.14-0+deb8u1 (cli) (built: Oct  4 2015 16:13:10) 
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
    with the ionCube PHP Loader (enabled) + Intrusion Protection from (unconfigured) v5.0.19, Copyright (c) 2002-2015, by ionCube Ltd.
  with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies

You can also check ioncube in the phpinfo() page in web browser.

Centos 7

Debian 8

How to install ProFTPD on Centos 7 or RHEL 7

1. Introduction

ProFTPD is an Open Source FTP Server. It is one of the most used, secure and reliable file transfer daemons on Unix environments, due to its file configurations simplicity speed and easy setup.This brief tutorial is going to show you how to install ProFTPD server in CentOS 7. It’a highly configurable and very stable with huge support from the Linux community.

2. Requirements

The OS of the server should be of Centos 7.
Before proceeding, the server should have a fully qualified hostname.
Also you need to install the EPEL repository. Please follow this command

# rpm -iUvh

3. Installation

You can install the ProFTPD as follows:

# yum install proftpd proftpd-utils

After the installation, start Proftpd daemon by issuing the following commands.

# systemctl start

You can check the ProFTPD version as follows:

[root@anu-centos7 ~]# proftpd -v
ProFTPD Version 1.3.5a
[root@anu-centos7 ~]# 

4. Create a ProFTPD user

For creating a group ftpgroup and user anu for ProFTPD. I will restrict the user anu with home directory as /ftp

# groupadd ftpgroup

Next you can add the user anu in ftpgroup:

# useradd  -G ftpgroup anu -s /sbin/nologin -d /ftp

Change the password for user ‘anu’

[root@server1 ~]# passwd anu
Changing password for user anu.
New password: <--ftppassword
Retype new password: <--ftppassword
passwd: all authentication tokens updated successfully.
[root@server1 ~]# 

Next you need to protect the /ftp directory from removing and renaming its content by any user, so we will change the directory permissions as follows:

# chmod -R 1777 /ftp/

Now you can do login with the user and password at ftp://Serverip
Here the user= 'anu' and password= 'anu'
You have installed Pro-FTP on Centos 7.


How to install and configure Foreman on CentOS 7 or RHEL 7

1. Introduction

Foreman is an open source tool that can help with the management of servers, by providing an easy way to interact with Puppet (or Chef) to automate tasks and application deployment. Foreman provides a robust web user interface, API, and CLI which can be used to provision, configure, and monitor your servers. It is suitable for infrastructures of all sizes, and works with most distributions of Linux.

In this tutorial, we will show you how to install Foreman with Puppet, and start using it to manage your servers. We will use Foreman for its reporting and External Node Classifier (ENC) capabilities, to ease the management of Puppet.

2. Features

  • Discover, provision and upgrade your entire bare-metal infrastructure
  • Create and manage instances across private and public clouds
  • Group your hosts and manage them in bulk, regardless of location
  • Review historical changes for auditing or troubleshooting
  • Extend as needed via a robust plugin architecture
  • Automatically build images (on each platform) per system definition to optimize deployment

3. Operating System

This article is based on RHEL 7 / CentOS 7 .

4. Prerequisites

Before installing Foreman, make sure you have setup a hostname and its dns properly for your server. You can edit the file /etc/hosts and update it as follows:( it is an example )  sapin-centos7

Also update the hostname file too inside /etc/hostname

5. Install Foreman on CentOS 7 / RHEL 7

Foreman can be installed in different methods. The recommended way is with the puppet based Foreman Installer but you may also use your distribution’s package manager or install directly from source.

The Foreman installer is a collection of Puppet modules that installs everything required for a full working Foreman setup. It uses native OS packaging (e.g. RPM and .deb packages) and adds necessary configuration for the complete installation.

The Foreman installer will install the necessary components such as the Foreman web UI, Smart Proxy, Passenger (for the puppet master and Foreman itself), and optionally TFTP, DNS and DHCP servers.

5.1. Configure EPEL, Puppet and Foreman repositories

Please run the below command for enabling the EPEL , pupet and forman repos.

# rpm -ivh
#rpm -ivh
#rpm -ivh

Enable the RHEL Optional and RHSCL repos on RHEL 7 ### run the below command.

# yum-config-manager --enable rhel-7-server-optional-rpms rhel-server-rhscl-7-rpms

5.2. Download Foreman installer

Run the following command to download Foreman installer.

# yum -y install foreman-installer

5.3. Start installation of foreman

# foreman-installer

Once the installation is completed, you will see an output like below where you would find the initial username and password to access the Foreman.

Installing             Done                                               [100%] [......................................................................................]
  * Foreman is running at
      Initial credentials are admin / KMq5Eoo8KHVtQPeh
  * Foreman Proxy is running at
  * Puppetmaster is running at port 8140
  The full log is at /var/log/foreman-installer/foreman-installer.log

Note down initial username and password, you need this for accessing Foreman’s dashboard.

Username :: admin
Password :: testpas

5.4. Configure Foreman (Optional)

If your Foreman host is not visible in Hosts –> All Hosts tab, you should run below command which will send the first Puppet report to Foreman, automatically creating the host in Foreman’s database.

# puppet agent --test

You will get an out like below

Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Caching catalog for
Info: Applying configuration version '1452312143'
Notice: Finished catalog run in 0.08 seconds

Puppet 3+ will show a warning the first time that the node can’t be found, this can be ignored.

6. Access Foreman Web Console

You can access the Foreman via web browser https://your-ip-address or https://FQDN

You should get login page, enter your Foreman credentials.


To list down the available hosts, goto Hosts –> All Hosts from Menu. Since we do not have any puppet clients, All Hosts tab would only list your Foreman host, with an “O” status. This indicates its status is OK, with no changes made on the last Puppet run. If your Foreman host is not shown here, check out configuring Foreman.

host formam

7. Download and Install NTP module

One of the more important requirement of puppet is to have an accurate time-keeping, to do this, we will install Puppet NTP module for managing the NTP service.

If you have Puppet 2.7.14 or higher, install the module automatically from Puppet Forge to our “production” environment (the default).

Use following command to install NTP module on Foreman (Puppet master) host.

# puppet module install -i /etc/puppet/environments/production/modules saz/ntp

You will get the below out.

Notice: Preparing to install into /etc/puppet/environments/production/modules ...
Notice: Downloading from ...
Notice: Installing -- do not interrupt ...
└── saz-ntp (v2.3.2)

In Foreman’s web console, go to Configure > Puppet Classes and click Import from hostname ( to read the available Puppet classes from the puppet master and populate Foreman’s database.

puppet class

Select the NTP module and click the update button.


After clicking the update button, you will see something like below. The “ntp” class will appear in the Puppet class list if installed correctly. Click on First NTP class on the left.


Now, Click the Smart Class Parameter and then select server list on the left side. Tick the Override checkbox so Foreman manages the “server list” parameter of the class, then click Submit.


Go to Hosts –> All Hosts, edit the Foreman host.


Go to Puppet Classes tab and expand the ntp module and click the + icon to add the ntp class to the host, then click submit.

This time, it will take you automatically to the host details page. Click on YAML, it will show the ntp class and the server list parameter, as passed to Puppet via the ENC (external node classifier) interface.



At last, run the following command on the Foreman host to see the NTP service automatically reconfigured by Puppet and the NTP module.

# puppet agent --test

Verify the installation of NTP module by going to Hosts –> All Hosts –> Select Foreman Host –> Reports –> Select latest report.


8. Conclusion


We have successfully configured Foreman and now it is ready to accept agents / nodes. It’s time to add some new hosts to Foreman.

9. Reference.

How to upgrade OpenSSL on Centos 7 or RHEL 7

1. Introduction

OpenSSL is a library that provides cryptographic functionality, specifically SSL/TLS for popular applications such as secure web servers, MySQl databases and email applications. The list parameters standard-commands, digest-commands, and cipher-commands output a list (one entry per line) of the names of all standard commands, message digest commands, or cipher commands, respectively, that are available in the present openssl utility.

2. Requirements

You may need an operating system RHEL 7 or Centos 7 in your dedicated or vps server. Please make sure to set a hostname for your server and its dns is pointing to the IP address of the server.

3. Installation

Get the current version with “openssl version” and “yum info openssl” command :

# openssl version
OpenSSL 1.0.1e-fips 11 Feb 2013

You can also check the available version in the vendors directory too.

# yum info openssl

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base:
 * epel:
 * extras:
 * updates:
Installed Packages
Name        : openssl
Arch        : x86_64
Epoch       : 1
Version     : 1.0.1e
Release     : 51.el7_2.1
Size        : 1.5 M
Repo        : installed
From repo   : updates
Summary     : Utilities from the general purpose cryptography library with TLS
            : implementation
URL         :
License     : OpenSSL
Description : The OpenSSL toolkit provides support for secure communications
            : between machines. OpenSSL includes a certificate management tool
            : and shared libraries which provide various cryptographic
            : algorithms and protocols.

Available Packages
Name        : openssl
Arch        : x86_64
Epoch       : 1
Version     : 1.0.1e
Release     : 51.el7_2.2
Size        : 711 k
Repo        : updates/7/x86_64
Summary     : Utilities from the general purpose cryptography library with TLS
            : implementation
URL         :
License     : OpenSSL
Description : The OpenSSL toolkit provides support for secure communications
            : between machines. OpenSSL includes a certificate management tool
            : and shared libraries which provide various cryptographic
            : algorithms and protocols.

To download the latest version of OpenSSL, do as follows:

# cd /usr/local/src
# wget
# tar -zxf openssl-1.0.2-latest.tar.gz

To manually compile OpenSSL and install/upgrade OpenSSL, do as follows:

# cd openssl-1.0.2a
# ./config
# make
# make test
# make install

If the old version is still displayed or installed before, please make a copy of openssl bin file :

# mv /usr/bin/openssl /root/
# ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl

Now verify the OpenSSL version.

# openssl version
OpenSSL 1.0.2e 3 Dec 2015

Note: Compiling Openssl major version may case issues with other system binaries. So please do the needfull to avoid the corruptions.

How to install and configure Linux, Apache, Mariadb and PHP (LAMP ) on Centos7 or RHEL7

1. Introduction

Short for Linux, Apache, MySQL and PHP, an open-source Web development platform, also called a Web stack, that uses Linux as the operating system, Apache as the Web server, MySQL as the RDBMS and PHP as the object-oriented scripting language. Perl or Python is often substituted for PHP.

2. Requirements

You may need an operating system RHEL 7 or Centos 7 in your dedicated or vps server. Please make sure to set a hostname for your server and its dns is pointing to the IP address of the server.

3. Installation

Please proceed with the following step by step procedures:

3.1 Install Apache

Apache2 is directly available as a CentOS 7.0 package, therefore we can install it like this:

# yum -y install httpd

Now configure your system to start Apache at boot time.

# systemctl start httpd.service
# systemctl enable httpd.service

Now direct your browser to http://your-IP, and you should see the Apache2 place holder page:


3.2 Install MariaDB

To install MySQL, we do install mariadb like this:

# yum -y install mariadb-server mariadb

Then we create the system startup links for MySQL (So that MySQL starts automatically whenever the system boots) and start the MySQL server:

# systemctl start mariadb.service
# systemctl enable mariadb.service

Set passwords for the MySQL root account:

# mysql_secure_installation

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] 
New password: <--yourmariadbpassword
Re-enter new password: <--yourmariadbpassword
Password updated successfully!
Reloading privilege tables..
 ... Success!

By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them.  This is intended only for testing, and to make the installation go a bit smoother.  You should remove them before moving into a production environment.

Remove anonymous users? [Y/n] <--ENTER
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] <--ENTER
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] <--ENTER
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] <--ENTER
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB installation should now be secure.
Thanks for using MariaDB!

3.3 Install PHP

We can install PHP5 and the Apache PHP5 module as follows:

# yum -y install php php-mysql

We must restart Apache afterwards:

# systemctl restart httpd.service

Testing PHP5 / Getting Details About Your PHP5 Installation

# vi /var/www/html/info.php

Now add the following phpinfo code content in this file.


Now we call that file in a browser (e.g. http://Your IP/info.php):


You may need We have successfully configured Apache2 , mysql and php.

How to install PHPMyadmin on centos 7 or RHEL 7

1. Introduction

There are many ways to access and manage databases. There are dedicated database applications that allow you to manipulate databases as well as manage access to them.

Another method is to directly connecting to the database server and running SQL statements using command-line utilities, although this is for highly advanced database administrators or someone who’s really brave. Using terminal consoles to manage databases isn’t recommended for new users or those just starting with managing database servers.

The third and most popular method is to manage database servers using web browsers. This is true especially for MySQL or MariaDB databases. Using web browser to access and manage databases is the fastest and easiest way yet. With phpMyAdmin tool, one can perform almost any database functions from the browser.

This article is going to show you how to install phpMyAdmin and use your favourite web browsers to manage MySQL or MariaDb databases in CentOS 7 or RHEL 7.

2. Requirement

If you have a fresh server, you should configure lamp stack. Please read my article from here to know how to configure a LAMP stack. The following are the software requirement for this installation.

  • Operating System : Centos 7
  • Web server : Apache 2.4
  • PHP version : 5.4
  • Databae : MariaDB 5.5

3. Install phpMyAdmin

By default, centos 7 repository does not contains phpmyadmin package. we need to enable EPEL repository.The EPEL repo (Extra Packages for Enterprise Linux) contains many additional packages, including the phpMyAdmin package we are looking for.

# yum install epel-release

Now we have configured EPEL repo in the server. Then just install PhpMyAdmin package:

# yum install phpmyadmin

After installation open /etc/httpd/conf.d/phpMyAdmin.conf file ( Apache config file for phpmyadmin ) and edit as follows.

# vi /etc/httpd/conf.d/phpMyAdmin.conf

#Apache 2.4
      # Require ip
      # Require ip ::1
      Require all granted

Save and close out. Then restart Apache service .

# systemctl restart httpd.service

Now our PhpMyAdmin is operational.Go and access phpMyAdmin by typing server hostname or IP address followed by phpmyadmin.

(eg.  http://server_IP/phpmyadmin)


Then you can login to the database using user name and password of mysql created during LAMP configuration.