After some research,I decide to use RockMongo.It is a MongoDB administration tool, written in PHP5, is Best in PHP world, more like PHPMyAdmin.You can download it from http://rockmongo.com/downloads.
Since it used PHP and Mongo db,when we deploy this app to the BlueMix,there are some steps we need to do.
1.Unzip the download package to specified folder. For exmaple c:\rockmongo
2.Create a manifest.yml in the c:\rockmongo.The manifest document has captured all of the configuration that we entered above for the application push into a description of the application deployment. Once you have a manifest.yml file, you can modify it however you would like.Copy the below content to this manifest.yml
---
applications:
- name: php-mongoAdmin
memory: 128M
instances: 1
path: .
buildpack: https://github.com/dmikusa-pivotal/cf-php-build-pack
3.Since this php application need to use mongo module,so you need to included php_mongo in the list of extensions in the buildpack options file. This is documented here:
https://github.com/dmikusa-pivotal/cf-php-build-pack/blob/master/docs/config.md#php-extensions
So we need to create a folder named .bp-config under your project and create a options.json file which will include php extension ,so when you install php buildpack it will install the dependency based on this options.json file.
4.Copy the below content to the options.json
{
"WEB_SERVER": "httpd",
"PHP_EXTENSIONS": ["bz2", "zlib", "curl", "mcrypt", "mongo"]
}
5.When we config rockmongo db info we need to know the mongo db name,ip ,user name ,password etc info.In order to get this kind of info,we double click the mongo db service,choose the application used this service then find the env log under the Files and Logs directory.You can get db credential info.
6.Open the config,php change the setting value based on the step5.You can add multiple server in this configuration file.
$MONGO["servers"][$i]["mongo_name"] = "192.155.236.166";//mongo server name
$MONGO["servers"][$i]["mongo_host"] = "192.155.236.166";//mongo host
$MONGO["servers"][$i]["mongo_port"] = "10014";//mongo port
$MONGO["servers"][$i]["mongo_timeout"] = 0;//mongo connection timeout
$MONGO["servers"][$i]["mongo_db"] = "db";//default mongo db to connect, works only if mongo_auth=false
$MONGO["servers"][$i]["mongo_user"] = "430f4c04-9ab0-49b2-95c8-226a3db5386f";//mongo authentication user name, works only if mongo_auth=false
$MONGO["servers"][$i]["mongo_pass"] = "a30d54be-2159-48ee-ae33-ca50d1ecc3ef";//mongo authentication password, works only if mongo_auth=false
$MONGO["servers"][$i]["mongo_auth"] = true;//enable mongo authentication?
7.Create a composer.json empty file. This file describes the dependencies of your project and may contain other metadata as well.
So by now all the configuration changes are done.The next step just deploy the app to the BlueMix.
Using the cloud foundry v6 cli, login to BlueMix and deploy your modified files using a PHP buildpack runtime.
# Step 0: cf login -a <api target url>
$ cf login -a https://api.ng.bluemix.net
# Step 1: under the rockmongo project folder
$ cf push
After successfully deployment,open the browser and visit the http://php-mongoadmin.ng.bluemix.net/,you will see below login screen
After input the db credential ,you can see Mongo db management UI.Now we can totally control our db in the cloud.
During my research ,I find some technical difficulty,so I post some questions on dw bluemix fourm and got my answers.It is a place to ask BlueMix usage questions since lots of IBM experts there.
Nice article !
ReplyDeleteBrilliant, thank you!
ReplyDeleteFor reference, initially trying to log into DB Name "db" resulted in this:
Failed to connect to: host:port: Authentication failed on database 'admin' with username 'xyz': auth fails
The patch described in https://code.google.com/p/rock-php/issues/detail?id=243 fixed it
Hi! This article is awesome! It works fantastic! now, I have a problem importing a js file exported from rockmongo. I've got the message "unauthorized". Someone knows why is it for?
ReplyDeleteI'm lost again =/
Thanks!
Lucas.-