Wednesday, April 16, 2014

Setting up ox for mongo

As per http://oxformongo.org/docs/Installation...

Made a virtual host in apache httpd.conf:

<VirtualHost *:80>

        ServerName ox.com

        ServerAlias www.ox.com *.ox.com

        DocumentRoot "/Library/WebServer/Documents/ox/app-blank/webroot"

</VirtualHost>

Modded /etc/hosts to add:

127.0.0.1 ox.com

127.0.0.1 www.ox.com

Put ox in:

/Library/WebServer/Documents/ox

Restart apache.

Inside app-blank:

chmod -R 775 tmp

Changed app-blank/config/app.php to reflect:

$mongo_config = array(

'set_string_id' => TRUE,

'persistent' => TRUE,

'host' => 'localhost', <--make sure this is not the same as your server alias

'database' => 'ox',

'port' => '27017',

'login' => '',

'password' => '',

'replicaset' => '',

);

Also in config/framework.php:

if (!defined('DIR_FRAMEWORK')) {

define ("DIR_FRAMEWORK",'/Libarary/WebServer/Documents/ox/ox/');

}

Started mongod with this command:

mongod --dbpath /Library/WebServer/Documents/ox/data/db/

And on mongo shell I just did:

use ox

to make the 'ox' database referenced in the app.php config file.

Having to install PHP's pear so I can install the mongo extension for PHP to make this work. In my /Users/me/Downloads/ I did:

curl -O http://pear.php.net/go-pear.phar

then

sudo php -d detect_unicode=0 go-pear.phar

as per

http://pear.php.net/manual/en/installation.getting.php

Installing pear I'm using these lcoations:

1. Installation base ($prefix) : /usr/bin/pear

2. Temporary directory for processing : /tmp/pear/install

3. Temporary directory for downloads : /tmp/pear/install

4. Binaries directory : /usr/bin/pear/bin

5. PHP code directory ($php_dir) : /usr/bin/pear/share/pear

6. Documentation directory : /usr/bin/pear/docs

7. Data directory : /usr/bin/pear/data

8. User-modifiable configuration files directory : /usr/bin/pear/cfg

9. Public Web Files directory : /usr/bin/pear/www

10. Tests directory : /usr/bin/pear/tests

11.        Name of configuration file : /Users/me/.pearrc

But it throws this ridiculous warning:

** WARNING! Old version found at /usr/bin/pear, please remove it or be sure to use the new /usr/bin/pear/bin/pear command

The 'pear' command is now at your service at /usr/bin/pear/bin/pear

** The 'pear' command is not currently in your PATH, so you need to

** use '/usr/bin/pear/bin/pear' until you have added

** '/usr/bin/pear/bin' to your PATH environment variable.

So I then edited /Users/me/.profile and appended :/usr/bin/pear/bin to one of my path exports. Fine. That didn't work.. had to do it to .bash_profile. Ahh, that worked. I guess .profile is a vestige of some yesteryear time? Does it only get run at login? Mine is at least four years old.

Anyway according to this mongodb-user Google group message now I do:

pecl install mongo

then add:

extension=mongo.so

to the end of your php.ini

I had to sudo it.

A bunch of stuff flies by. It asks:

Build with Cyrus SASL (MongoDB Enterprise Authentication) support? [no] :

...to which I pressed Enter (no).

A bunch more stuff... A LOT... flies by.

Finally I modified php.ini and restarted apache again. Progress is made, now I'm getting:

404 Error

File (root/index)was not found

if I just go to my URL http://ox.com/. However if I go to the URL http://ox.com/root/ then I get the basic page.

I note that in Ox_FlatAction.php I set DEBUG=TRUE and I see that in ll. 91-93:

$file = DIR_CONSTRUCT . $dir . DIRECTORY_SEPARATOR . $flat_file;

if($this->flat_file_dir) {

$file = $this->flat_file_dir . DIRECTORY_SEPARATOR . $flat_file;

}

So if flat_file_dir is specified as it is when in routes.php l. 6:

Ox_Router::add(WEB_ROOT, new Ox_FlatAction('root'));

So basically when the constructor of Ox_FlatAction gets called on its ll. 54-58:

public function __construct($file_dir=null, $layout = null)

{

$this->flat_file_dir = $file_dir;

$this->layout = $layout;

}

Then $flat_file_dir gets set to /root/ and then in ll. 91-93 above file gets made to be root/index which does not exist because it's referencing the base file system.

I guess we need a rewrite directive in httpd.conf? Well conveniently oxformongo.org's installation doc does not actually show the .conf file text (it's just blank white space :/_).

Anyway not gonna worry about it because they also say in their routes doc that "to set up the route for the webroot, we do:

        Ox_Router::add(WEB_ROOT, new Ox_FlatAction());

...which is different from the base project which had Ox_FlatAction('root'), as you'll note above. Well OK. Now it's working :D

1 comment:

  1. Arguably the most exciting technology currently on the .NET Framework, .NET Core is an open-source general-purpose development platform that Microsoft and the wider .NET community maintain. If you are a freelance net full stack developer, you can get more relevant projects on Eiliana.com, where top clients regularly post IT development projects.

    ReplyDelete