Install Mongo and MBString PHP module on RedHat

The following steps walks through the installation of mongo and mbstring modules for php. This is helpful when you are required to install specific versions of the modules along with your PHP package.
Installation on CentOS of php-mbstring is straightforward as you just can get the package from the Epel-repo or on the Optional Packages repo.

Steps:

Look at the currently installed modules
#php -m

Look at the currently installed version of php
#php -v

Look at the currently installed module packages
#rpm -qa | grep php

Make sure php-devel is installed. If already installed, skip this.
Install the php-devel package using yum
#yum install php-devel

If php-devel install fails due to compatibility issues, download
the correct rpm version on the red hat network package database website.
Install the correct version from rpm
#rpm -ivh php-devel-5.3.3-27.el6_5.x86_64.rpm

Download the required mongo version from the php pecl website
#wget http://pecl.php.net/get/mongo-1.5.4.tgz

Extract the file
#tar -zxvf mongo-1.5.4.tgz

Go inside the folder
#cd mongo-1.5.4

Prepare an exension for compiling
#phpize

Configure the package and compile
#./configure
#make
#make install

Create /etc/php.d/mongo.ini and add the exension line
#vi /etc/php.d/mongo.ini
extension=mongo.so

Verify that php mongo module is installed corectly
#php -m | grep mongo

Install the mbstring modules using yum.
#yum install php-mbstring

If installation fails due to compatibility issues, download
the correct rpm version on the red hat network package database website.
Install the correct version from rpm
#rpm -ivh php-mbstring-5.3.3-27.el6_5.x86_64.rpm

Verify that the mbstring string package is installed
#rpm -qa | grep php-mbstring

Verify that mbstring php module is installed correctly
#php -m | grep mbstring

Reload the httpd service to activate the modules. Or restart if needed be.
#/etc/init.d/httpd reload

Leave a Reply

Your email address will not be published. Required fields are marked *