Wanna configure MongoDB in Drupal 8? We can help you configure it.
Don’t worry, by a few configuration settings, we can configure Drupal to use MongoDB.
However, improper configuration settings and inactive MongoDB module may create error after installing it.
At Bobcares, we often get requests to set up MongoDB in Drupal sites as part of our Server Management Services.
Today, let’s get into the details and see how our Support Engineers configure Drupal 8 to use MongoDB and fix errors.
How we configure Drupal to use MongoDB?
1. Initially, we install MongoDB in the Linux based server using the following command.
apt-get install mongodb-10gen or yum install mongodb
2. After that, we install the MongoDB PHP driver.
pecl install mongo
3. Next, we configure PHP to use MongoDB. For that, we edit the php.ini file of the server and we add the following line.
extension=mongo.so
4. Again, to configure Drupal to use MongoDB, we download and install the Drupal MongoDB module.
5. Then, we create a file called local.settings.php and add the following code there.
#MongoDB
$conf['mongodb_connections'] = array(
'default' => array( // Connection name/alias
'host' => 'localhost', // Omit USER:PASS@ if Mongo isn't configured to use authentication.
'db' => '[YOURDATABASENAME]' // Database name. Make something up, mongodb will automatically create the database.
),
);include_once('./includes/cache.inc');
# -- Configure Cache
$conf['cache_backends'][] = 'sites/[SITENAME]/modules/mongodb/mongodb_cache/mongodb_cache.inc';
$conf['cache_class_cache'] = 'DrupalMongoDBCache';
$conf['cache_class_cache_bootstrap'] = 'DrupalMongoDBCache';
$conf['cache_default_class'] = 'DrupalMongoDBCache';
# -- Don't touch SQL if in Cache
$conf['page_cache_without_database'] = TRUE;
$conf['page_cache_invoke_hooks'] = FALSE;
# Session Caching
$conf['session_inc'] = 'sites/[SITENAME]/modules/mongodb/mongodb_session/mongodb_session.inc';
$conf['cache_session'] = 'DrupalMongoDBCache';
# Field Storage
$conf['field_storage_default'] = 'mongodb_field_storage';
# Message Queue $conf['queue_default_class'] = 'MongoDBQueue';
?>
Note: we replace the placeholders [YOURDATABASENAME] and [SITENAME] when required.
How we fixed the common errors
At Bobcares, where we have more than a decade of expertise in managing servers, we see many customers face problems while managing MongoDB.
Now, let’s see the major reasons for this MongoDB related errors and how our Support Engineers fix the top errors.
Inactive MongoDB Module
Recently. one of our customers contacted us with a problem regarding MongoDB. After installing MongoDB on the server, it didn’t work properly.
On checking, our Support Engineers found that MongoDB Module wasn’t enabled on the Drupal server.
Therefore, we took the following steps to enable the MongoDB Module.
1. Firstly, we login to the Drupal administration panel.
2. Next, we go to the modules management page and we disabled the block module from Drupal Core. Because this conflicts with the MongoDB Block module and Drupal will not allow you to activate the MongoDB plugin.
3. After that, enable the remaining module as follows.
Wrong file location
Often customers make errors while configuring Drupal to use MongoDB. Because they may create the local.settings.php file in the wrong location. So, it does not work as we expect.
Therefore, our Support Engineers make sure that local.settings.php is created in the same directory as settings.php.
Hence, the MongoDB will work with Drupal without any error.
[Need assistance to integrate MongoDB into Drupal We’ll help you.]
Conclusion
In short, due to the wrong file location and inactive MongoDB module, integration of Drupal 8 with MongoDB doesn’t work. Today, we saw how our Support Engineers configured Drupal to use MongoDB and fixed this error.
0 Comments