![]() ![]() The most considerable differences are that MySQL is written using SQL queries, while MongoDB is focused on BSON (Binary JSON). $ sudo /opt/local/etc/LaunchDaemons/2/apache2.Mongo is an open source schemaless database system which is very different from the more popular MySQL. Now restart Apache and you’ll be ready to use MongoDB in PHP. ![]() You can add that line at the end of the file but it is supposed to be in the "Dynamic Extensions". That last line means that you have to edit yourself the php.ini file, which in my case is in /opt/local/etc/php5/php.ini, and add the extension load for mongo. When it finishes the installation you will see something like this: Build process completed successfully Installing '/opt/local/lib/php/extensions/no-debug-non-zts-20090626/mongo.so' install ok: channel:///mongo-1.3.4 configuration option "php_ini" is not set to php.ini location You should add "extension=mongo.so" to php.ini Now we have to install the PHP driver with pecl: $ sudo pecl install mongo So in ~/.bash_profile: export PATH=/opt/local/bin: /opt/local/lib/php/pear/bin:$ If you use php54 you have to install them like this: $ sudo port install pear-PEARĪnd then add this path to your PATH environment variable: /opt/local/lib/php/pear/bin Run this commands to see if they return some value: $ pear version $ pecl version More configuration options: Installing the PHP driver for MongoDBīefore installing the driver we need to be sure that we have pear and pecl installed. You can load and unload MongoDB with those commands (using them will make MongoDB autoload on boot!): $ sudo port load mongodb $ sudo port unload mongodb You can then run mongod specifying that configuration file: $ sudo mongod -f /opt/local/etc/mongodb/nfĬreate these aliases to have an smaller command to start and stop mongodb: alias mongodbstart='sudo mongod -f /opt/local/etc/mongodb/nf' alias mongodbstop="mongo -eval \"db.getSiblingDB('admin').shutdownServer()\""Īn easier way is to use the load/unload option that comes with MacPorts that defines all those configuration values in /opt/local/etc/LaunchDaemons// file. Supply another path as the data storage folder with the -dbpath option: $ mongodb -dbpath /var/lib/mongoĪnd the best of all, create the necessary paths for data and log files and also the configuration file to specify those paths: $ sudo mkdir /opt/local/var/db/mongodb $ sudo mkdir /opt/local/var/log/mongodb $ sudo touch /opt/local/var/log/mongodb/mongodb.log $ sudo mkdir /opt/local/etc/mongodb/Īdd this to /opt/local/etc/mongodb/nf file: # Store data alongside MongoDB instead of the default, /data/db/ dbpath = /opt/local/var/db/mongodb # Only accept local connections bind_ip = 127.0.0.1 # Running as daemon fork = true # Take log logpath = /opt/local/var/log/mongodb/mongodb.log logappend = true Create this directory or give existing directory in -dbpath. ![]() ![]() MongoDB uses /data/db as the default path for storing its data files, but it's likely that your won't have that folder and running MongoDB server ( mongod) will end with this error: ********************************************************************* ERROR: dbpath (/data/db/) does not exist. Installing MongoDB with MacPorts is as easy as running this command: $ sudo port install mongodb Installing and configuring MongoDB with MacPorts ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |