Monthly Archives: May 2016

How To Install MongoDB on cPanel server

How To Install MongoDB on cPanel server

MongoDB is an open-source document database designed for easy of development and scaling. For more information please visit , You can also download the linux tar file for manual installation as per your customized needs. Today i had a chance to install MongoDB on one of our cpanel based server so just wanted to write down how its installed.

Note: This was installed on CentOS release 6.7 (Final) Cpanel based server. Installing it with the yum manager was lot easier and quicker.

Step 1.) Installing repo

cd /etc/yum.repos.d
nano -w mongodb.repo

Copy and Paste the below given code and save the file.

[mongodb] name=MongoDB Repo

Step 2.) Installing the package MongoDB

yum install mongo-10gen mongo-10gen-server

Step 3.) Configure it to automatically start after reboots

chkconfig mongod on

Start MongoDB:

service mongod start

Starting mongod: [OK]

Step 4.) Installing MongoDB PHP Extension

pecl install mongo

Let the process complete and at the end you should see the following text.

Build complete.
Don’t forget to run ‘make test’.

running: make INSTALL_ROOT=”/root/tmp/pear/pear-build-rootv6pAQg/install-mong-1.6.13″ install
Installing shared extensions: /root/tmp/pear/pear-build-rootv6pAQg/install-mongo-1.6.13/usr/local/lib/php/extensions/no-debug-non-zts-20121212/
running: find “/root/tmp/pear/pear-build-rootv6pAQg/install-mongo-1.6.13” | xargs ls -dils
6292373 4 drwxr-xr-x 3 root root 4096 Apr 9 02:58 /root/tmp/pear/pear-build-rootv6pAQg/install-mongo-1.6.13
6292524 4 drwxr-xr-x 3 root root 4096 Apr 9 02:58 /root/tmp/pear/pear-build-rootv6pAQg/install-mongo-1.6.13/usr
6292525 4 drwxr-xr-x 3 root root 4096 Apr 9 02:58 /root/tmp/pear/pear-build-rootv6pAQg/install-mongo-1.6.13/usr/local
6292526 4 drwxr-xr-x 3 root root 4096 Apr 9 02:58 /root/tmp/pear/pear-build-rootv6pAQg/install-mongo-1.6.13/usr/local/lib
6292527 4 drwxr-xr-x 3 root root 4096 Apr 9 02:58 /root/tmp/pear/pear-build-rootv6pAQg/install-mongo-1.6.13/usr/local/lib/php
6292528 4 drwxr-xr-x 3 root root 4096 Apr 9 02:58 /root/tmp/pear/pear-build-rootv6pAQg/install-mongo-1.6.13/usr/local/lib/php/extensions
6292529 4 drwxr-xr-x 2 root root 4096 Apr 9 02:58 /root/tmp/pear/pear-build-rootv6pAQg/install-mongo-1.6.13/usr/local/lib/php/extensions/no-debug-non-zts-20121212
6292523 1836 -rwxr-xr-x 1 root root 1878374 Apr 9 02:58 /root/tmp/pear/pear-build-rootv6pAQg/install-mongo-1.6.13/usr/local/lib/php/extensions/no-debug-non-zts-20121212/

Build process completed successfully
Installing ‘/usr/local/lib/php/extensions/no-debug-non-zts-20121212/’
install ok: channel://
Extension mongo enabled in php.ini

Restart Apache to apply changes:

service httpd restart

Verify installation with this command:

php -i | grep mongodb -i

If you see the MongoDB extension in the output, That’s it you are all set.

How To Install GMP on cPanel – Centos servers.

How To Install GMP 6

GNU MP or GMP is a free library for arbitrary precision arithmetic, operating on signed integers, rational numbers, and floating point numbers. There is no practical limit to the precision except the ones implied by the available memory in the machine GMP runs on. GMP has a rich set of functions, and the functions have a regular interface.

The main target applications for GMP are cryptography applications and research, Internet security applications, algebra systems, computational algebra research, etc.

GMP is carefully designed to be as fast as possible, both for small operands and for huge operands. The speed is achieved by using fullwords as the basic arithmetic type, by using fast algorithms, with highly optimised assembly code for the most common inner loops for a lot of CPUs, and by a general emphasis on speed.

For install GMP library in cPanel server follow this instruction ;


cd /usr/local/src


tar -xjvf gmp-*

cd gmp-6.1.0



make check

make install


Edit or create new file /var/cpanel/easy/apache/rawopts/all_php5

vi /var/cpanel/easy/apache/rawopts/all_php5

and add this line ;


Install gmp-devel ;

yum install gmp-devel

Rebuild apache using this command ;

/scripts/easyapache --build
Check PHP should be added:
php -i | grep -i gmp

et voila.

How to redirect from main site to subfolder

redirect from main site to subfolder

If you are trying to redirect from to this requires a special .htaccess config to avoid creating a loop.

You can use the following in the .htaccess of the main site.

Replace with your own website, and replace newfolder with the name of the folder you want to redirect to.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?$
RewriteCond %{REQUEST_URI} !^/newfolder/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /newfolder/$1
RewriteCond %{HTTP_HOST} ^(www.)?$
RewriteRule ^(/)?$ newfolder/index.php [L]