Hi everybody, today we'll learn about RockMongo and how we can setup it on our CentOS 6 or CentOS 7. RockMongo is an Open Source tool developed for MongoDB administration tool which is written in PHP 5. It is one of the best tool for MongoDB administration available currently. It provides a very good user-friendly way to create database, collections, documents, query collections, import and export data and insert and fetch documents using a web interface. It is a lot similar to PhpMyAdmin tool.
We'll need to make sure that we have the following prerequisites fulfilled to configure RockMongo.
- A web server running PHP
- PHP 5 or higher with session support
- the php_mongo extension for MongoDB
- A running MongoDB database system
So, here are the quick and simple steps by which we can easily install RockMongo on our CentOS 6 or 7 Operating System.
1. Installing a Web Server and Php 5
First of all, we'll need to install a web server supporting PHP. We'll install Apache Web Server in this tutorial for a web server and we'll install Php 5 out of the box. To install them we'll need to run the following command in a shell or a terminal.
# yum install httpd php-devel php
2. Installing PHP Mongo Extension
Then, we'll install PHP Mongo Driver extension which is essential for MongoDB. We'll first need to install git so that we can pull the driver package out of github.
# yum install git
Now, to configure and install the mongo php driver, here are the steps to be followed.
# cd /tmp/
# git clone https://github.com/mongodb/mongo-php-driver.git
# cd mongo-php-driver/
# make all
# make install
After installing Php Mongo Extenstion, we'll now download our RockMongo and install it on our machine.
3. Downloading RockMongo
Now, we'll download our latest RockMongo from github to /tmp/ folder in our CentOS box. To do so, we'll need to run the following command in a shell or terminal.
# cd /tmp/
# wget https://github.com/iwind/rockmongo/archive/master.zip
After downloading it with wget, we'll want to extract it.
# unzip master.zip
Then, we'll want to move the folder to /var/www/html/ which is the default webroot of Apache Web Server so that the directory will be accessible to the internet.
# mv rockmongo-master/ /var/www/html/rockmongo
4. Configuring Php
Now, we'll need to configure php.ini which is located inside /etc/ directory. We'll can open the file with our favorite text editor.
# nano /etc/php.ini
Now, we'll want to append the file with the below configuration.
5. Restarting Apache Web Server
After all the above task is completed, we'll finally want to restart our Apache Web Server.
# systemctl restart httpd.service
Now, after done we'll wanna goto http://ip-adress/rockmongo/ or http://my-website/rockmongo/ according to the configuration using our favorite browser. Then, we'll want to login to the page with the credential required username and password as admin and admin respectively by default.
Inorder to change the default username and password of the login of RockMongo can be changed by editing /var/www/html/rockmongo/config.php file with our favorite text editor
# nano /var/www/html/rockmongo/config.php
Now, we'll need to replace admin/admin with the desired username and password one wishes to change.
$MONGO["servers"][$i]["control_users"]["admin"] = "admin";
6. Configuring Firewall
If we have firewall enabled, we'll want to open port 80 for Apache Web Server so that RockMongo will be accessible.
On CentOS 6
# iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
On CentOS 7
# firewall-cmd --zone=dmz --add-port=2888/tcp --permanent
# firewall-cmd --reload
Now, we'll want to restart our Apache Web Server as shown in above step 5.
Finally, we have successfully installed RockMongo in our CentOS 6.x/7.x machine. RockMongo is an awesome tool for MongoDB Administration having pretty cool user interface as like of Phpmyadmin. So, if you have any questions, suggestions, feedback please write them in the comment box below. Thank you ! Enjoy RockMongo :-)