Setup Drupal 7 Panopoly distribution with mongoDB on CentOS 7

The mongoDB provides high performance, high availability, and easy scalability. Using it with Drupal, will take some load off its SQL database. The read/write SQL procedures in Drupal functions like: session, log entries from watchdog, cache, fields, queue and block can be handled by mongoDB Drupal module. And this will greatly improve the perfomance of your Drupal site.

As of this writing the mongodb module is still in 7.x-1.0-rc2 version and obviously is not stable. Another is that this module does not run 100% mongoDB database on your Drupal and still some components are dependant on SQL.

We will take a look on how to setup mongoDB and integrate it with Drupal 7 Panopoly distribution. Panopoly profile is a very good building foundation for a Drupal site. The following procedures are tested on my Linode server running Centos 7 64-bit Linux distribution. And it is required that you have "drush" installed in your system.

Setup Mongodb service

  1. Use the mongoDB repo and configure the package management system to make it available in our yum:
    vi /etc/yum.repos.d/mongodb-org-3.0.repo

    ... and write the following as content of this repo file:

    name=MongoDB Repository
  2. Execute the the following command to install mongoDB:
    yum install mongodb-org.x86_64
  3. Modify the mongod.conf:
    vi /etc/mongod.conf

    ... and add the following config items:


    The "auth=true" to enable the security and "smallfiles=true" to solve this issue.

  4. Create a super user:

    ... a mongoDB prompt will show and execute the following commands:

    use admin
        user: "admin",
        pwd: "password",
        roles: [ "root" ]

    Next time you login to your mongo command prompt, execute this command:

    mongo -u admin -p --authenticationDatabase admin
  5. Register mongoDB's log to logrotate:
    vi /etc/logrotate.d/mongodb

    Have the following scripts as content:

    /var/log/mongodb/*.log {
      rotate 30
      /bin/kill -SIGUSR1 `cat /var/lib/mongo/mongod.lock 2> /dev/null` 2> /dev/null || true
  6. Run the mongoDB service:
    systemctl start mongod.service

Install mongodb PHP driver

  1. Install the tools for building PHP extensions:
    yum install php-devel php-pear
  2. Download the mongodb PHP driver from github:
    cd /opt
    git clone
  3. Compile and install the mongodb PHP driver:
    cd mongo-php-driver
    sudo make install
    echo "" > /etc/php.d/mongo.ini
  4. Restart your web server:
    systemctl restart httpd.service

Setup mongoDB in Drupal

  1. Download Drupal 7 Panopoly distro into your web directory (in my case its "/home/webfoobar/public_html") and install it:
    cd /home/webfoobar/public_html
    drush dl panopoly
    mv panopoly-7.x-1.23/{.,}* .
    rm -rf panopoly-7.x-1.23
    drush si panopoly --account-name=admin --account-pass=password --db-url=mysql://admin:password@localhost/mydatabase

    Note: Ignore the errors. Those errors will not prevent us from running our Drupal site.

  2. Download and enable the mongodb module:
    drush dl mongodb
    drush dis block
    drush en mongodb_block_ui mongodb_watchdog mongodb_field_storage mongodb_session mongodb_cache mongodb_queue mongodb_block mongodb_migrate mongodb

    Note: Ignore the errors. Those errors will not prevent us from running our Drupal site.

  3. Edit your Drupal settings file:
    vi sites/default/settings.php

    ... and append these PHP codes:

    * MongoDB configurations
    $conf['mongodb_connections'] = array(
      // Connection name/alias
      'default' => array(
        // Omit USER:PASS@ if Mongo isn't configured to use authentication.
        'host' => 'mongodb://admin:password@localhost',
        // Database name
        'db' => 'mymongodatabase',
    #$conf['mongodb_debug'] = TRUE;
    $conf['cache_backends'][] = 'sites/all/modules/mongodb/mongodb_cache/';
    $conf['cache_default_class'] = 'DrupalMongoDBCache';
    // The 'cache_form' bin must be assigned to non-volatile storage.
    $conf['cache_class_cache_form'] = 'DrupalDatabaseCache';
    // Don't touch SQL if in Cache
    $conf['page_cache_without_database'] = TRUE;
    $conf['page_cache_invoke_hooks'] = FALSE;
    $conf['field_storage_default'] = 'mongodb_field_storage';
    $conf['mongodb_watchdog'] = 'watchdog';
    $conf['mongodb_watchdog_items'] = 10000;
    $conf['watchdog_limit'] = WATCHDOG_ERROR;
    $conf['mongodb_session'] = 'session';
    $conf['session_inc'] = 'sites/all/modules/mongodb/mongodb_session/';
    $conf['cache_session'] = 'DrupalMongoDBCache';
  4. Run the drush commands to migrate the Drupal fields:
    drush mongodb-migrate-prepare
    drush mongodb-migrate
  5. Congratulations! Login to your new Drupal 7 Panopoly with mongoDB backed site.

You may want also to check this article: Setup Rock Mongo web interface.

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.