PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, August 1, 2022

[FIXED] How to run MongoDB using PM2

 August 01, 2022     mongodb, pm2, server, vps     No comments   

Issue

How do I run MongoDB using PM2? I'm using a Linux VPS (CentOS) and I tried doing this:

pm2 mongod

^ and that works but the problem is I need to bind IP and DBPath name

pm2 mongod -dbpath /home/[ommitted]/data/db --bind_ip [ommitted] -auth

^ But that doesn't work because of PM2 flags. So how can I run it using PM2 or at least make it so it doesn't shut down when I close the terminal


Solution

You can create an SH file that runs the command, then run the SH file.

1. For example, name it "run.sh"
2. Open/edit file
3. Add this to the first line of the file mongod -dbpath /home/[ommitted]/data/db --bind_ip [ommitted] -auth
4. pm2 start run.sh

Another way that you can do is this;

pm2 start "mongod -dbpath /home/[ommitted]/data/db --bind_ip [ommitted] -auth"


Answered By - Felix Isaac
Answer Checked By - Gilberto Lyons (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing