How to Connect MongoDB to cPanel
🚀 How to Connect MongoDB to cPanel
MongoDB is a flexible NoSQL database, but it’s not included by default in WHM/cPanel. You’ll need to install MongoDB manually on the server and then connect it with PHP/your application.
✅ Step 1: Add MongoDB Repository
Log in as root via SSH and create a new repo file:
Paste this inside:
Save & exit (CTRL+O, CTRL+X).
✅ Step 2: Install MongoDB Packages
Run:
✅ Step 3: Enable & Start MongoDB
Check if it’s running:
✅ Step 4: Install PHP MongoDB Extension
To allow PHP apps (like Laravel, custom apps, etc.) to talk to MongoDB:
Then enable the extension:
Restart Apache:
✅ Step 5: Verify Installation
Check if MongoDB extension is active:
✅ Step 6: Connect PHP App to MongoDB
In your PHP code (inside cPanel user account), you can connect like this:
Share
What's Your Reaction?
Like
0
Dislike
0
Love
0
Funny
0
Angry
0
Sad
0
Wow
0
