MongoDB Installation
- 1 Requirements
- 2 Installation
- 2.1 Intalling the MongoDB server
- 2.2 Installing the MongoDB PHP Driver
- 2.3 Securing the MongoDb Server
- 2.3.1 Setting up the Admin User
- 2.3.2 Enabling Secure Login
- 2.3.3 Testing Login
- 2.3.3.1 No Access
- 2.3.3.2 Admin Access
- 2.4 Configuring PCR-360
Optional Feature
Grid Indexing is an optional feature. If your organization does not require it, you can disable this functionality.
This change is made by adding a configuration option to the PCR-360 iniconstants.GRID_INDEXING_ENABLED = false
Requirements
Database Setup:
MongoDB is required to enable Grid Indexing.
It can be installed locally on the same machine as the application or hosted remotely on a separate server.
Security and Authentication
Authentication: MongoDB must be configured to require authentication to ensure security. This means users will need valid credentials to access the database.
Credentials
The application requires login credentials (username and password) to connect to MongoDB.
These credentials must have permissions to create and manage databases and tables.
Installation
Intalling the MongoDB server
https://www.mongodb.com/docs/manual/administration/install-on-linux/
Installing the MongoDB PHP Driver
https://www.mongodb.com/docs/drivers/php-drivers/
Securing the MongoDb Server
Setting up the Admin User
The password should be alphanumeric and can include hyphens - and underscores _ but should avoid special characters like ^#@%* and quotes ' “ because it can cause issues with the terminal login used by the MongoDb PHP Driver.
mongosh
>
use admin
>
db.createUser(
{
user: "pcr360",
pwd: passwordPrompt(),
roles: [ { role: "userAdminAnyDatabase", db: "admin" }, "readWriteAnyDatabase" ]
}
)
>
exit
Enabling Secure Login
vi /etc/mongod.conf
>
# find
#security:
# and replace with
security.authorization: enabled
>
:wq
# Restart
sudo systemctl restart mongod
sudo systemctl status mongod
Testing Login
No Access
mongosh
>
show dbs
>
MongoServerError: command listDatabases requires authentication
>
exit
Admin Access
Configuring PCR-360
Encrypting a Password
PCR-360's CLI can be used to encrypt MongoDB passwords
Database Connection
PCR-360 configuration Options
Ooptions must be placed in the correct section for the environment. Usually, test or prod
the INI is usually located /var/www/pcr360/configs/pcr360.ini
Disabling the Index
Setting this constant to false will disable the indexing and prevent any attampted connection to MongoDB. This is intended to disable the index for customers whose hardware cannot support it.
Indexed grids use the Index, by default, for grid queries
To disable, set this config option to false