MongoDB Tutorial 2: Introduction: Difference between revisions

From The Uniform Server Wiki
Jump to navigation Jump to search
(New page: {{Nav MongoDB Tutorial 2}} '''''MongoDB''''' == Introduction == Previous tutorial covered an independent implementation of MongoDB advantage of this ...)
(No difference)

Revision as of 13:10, 1 August 2010

 

MongoDB Plugin
UniServer 6-Carbo.

MongoDB

Introduction

Previous tutorial covered an independent implementation of MongoDB advantage of this it can be run alongside any version of Uniform Server or any WAMP stack.

You need to download a separate driver to access MongoDB server using PHP. If you prefer a browser interface to control the server for example phpMoAdmin requires another download.

This tutorial looks at integrating the above into Uniform Server 6-Carbo. Advantages of this all components installed using a plugin, reduction in footprint. In addition access to Uniform Server’s control allowing both MongoDB and Apache to be run from a common interface.

Top

Downloads

We require a working server to this we will add components from the tutorial plugin.

Uniform Server

Download Uniform Server 6-Carbo and extract to any folder for example z_mongo

For download details see MongoDB Introduction (Main Start page)

Tutorial Plugin Download

Download the tutorial plugin and extract to any folder for example mongo_temp

For download details see MongoDB Introduction (Main Start page)

Top

Overview

A plugin contains all components we wish to overlay on Uniform Server. Create a new folder named mongodb_b this will contain a folder structure that maps that of Uniform Server. It contains only plugin components these are copied from our reference-working server.

First we create a reference-server by coping appreciate components from the tutorial plugin. This contains a complete set of components (independent, plugin, authentication, no authentication etc) only a sub-set is required for our new plugin.

Reference-server in a test bed once we have tested and moved the finished componets over to mongodb_b it can be deleted.


Top

Basic structure

First we need to build a basic test structure. Appropriate components are copied from mongo_temp to z_mongo and reflected in mongodb_b

  • Copy folder: mongo_temp\UniServer\home\admin\www\tutorial_phpMoAdmin
  • To: z_mongo\UniServer\home\admin\www\tutorial_phpMoAdmin
  • Rename copied folder to phpMoAdmin
  • ---
  • Copy files
    • mongo_temp\UniServer\usr\local\mongo_tutorial\WinBinder_1\a_test\mongo_tutorial2.phpw
    • mongo_temp\UniServer\usr\local\mongo_tutorial\WinBinder_1\a_test\mongo_tutorial2.bat
  • To folder: z_mongo\UniServer\unicon\tray_menu_2
  • ---
  • Copy folder: mongo_temp\UniServer\usr\local\php
  • To folder: (allow overwrite) z_mongo\UniServer\usr\local
  • ---
  • In folder z_mongo\UniServer\usr\local create a new folder named mongo
  • Copy folder: mongo_temp\UniServer\usr\local\mongo_tutorial\bin
  • To folder: z_mongo\UniServer\usr\local\mongo
  • ---
  • Copy folder: mongo_temp\UniServer\usr\local\mongo_tutorial\data
  • To folder: z_mongo\UniServer\usr\local\mongo
  • ---
  • Create a new folder z_mongo\temp
  • Copy to it file: mongo_temp\UniServer\usr\local\mongo_tutorial\Cheat_folder\mongo_db_inc.php

Top

Rename and clean-up

Some of folders copied contain files that are not required these can be deleted. While we ar at it some files are better renamed.

  • Rename: z_mongo\UniServer\unicon\tray_menu_2\mongo_tutorial2.bat to Run_mongo_db.bat
  • Rename: z_mongo\UniServer\unicon\tray_menu_2\mongo_tutorial2.phpw to mongo_db.php
  • Delete: z_mongo\UniServer\usr\local\mongo\bin\config_auth.ini
  • Delete: z_mongo\UniServer\usr\local\mongo\bin\mongo_name_password
  • Rename: z_mongo\UniServer\usr\local\php\mongo_tutorial_cli.ini to mongo_cli.ini

Top

Test

Lets run a quick test to see if every thing was copied correctely

  • Run file: z_mongo\UniServer\unicon\tray_menu_2\Run_mongo_db.bat

Produces the followinf error:

Warning: dl(): Unable to load dynamic library 'C:\php5\php_winbinder.dll' - The specified module could not be found.
 in C:\z_mongo\UniServer\unicon\tray_menu_2\winbinder\winbinder.php on line 15

Fatal error: WinBinder extension could not be loaded.
 in C:\z_mongo\UniServer\unicon\tray_menu_2\winbinder\winbinder.php on line 16
Press any key to continue . . .

First line is interesting 'C:\php5\php_winbinder.dll' PHP has tried all paths and finally looked in the default location.

The error message is misleading does not point to a true cause if you do have a path C:\php5 chances are you installed PHP manually.

Errors at lines 15 and 16 prove windinder paths are correctly picked up.

Reason for the error WinBinder was not enabled in the configuration file

Edit file z_mongo\UniServer\usr\local\php\mongo_cli.ini un-comment the winbinder extension as shown:

[PHP]
extension=php_winbinder.dll

extension_dir = "./extensions"
error_reporting = E_ALL 
date.timezone = "Europe/London"
extension=php_mongo.dll

Rerun the batch file and a window with a few buttons will greet you.

This confirms WinBinder is working correctly.

Top

Summary

The above gives us a working environment.

We are not interested in the windows thingy until a working alternative control is in place. This is needed to test and debug the windows application.

Next page covers alternative control.

Top