Articles in this section

How to install MongoDB database server in Plesk?

kb: how-to Plesk for Linux

Applicable to:

  • Plesk for Linux

How to install MongoDB in Plesk?

Answer

Support for MongoDB database servers is not yet an implemented feature on Plesk.
All current supported Third-Party components can be found in Plesk Software Requirements.

As an alternative, MongoDB can be deployed in local or remote Docker container:

Warning: Below steps are done on your own risk! Even being installed via Docker. MongoDB should still be managed manually, Plesk has no controls to manage it (creating DBs, etc.).

Click here to expand Docker instructions

Note: Local Docker service is not supported on Windows and CloudLinux. For more information refer to the Plesk Administrator's Guide.

Note: Installing MongoDB as a Docker container on Ubuntu 22.04 or later is not possible because the mongodb-clients package is not available on these OS versions repositories.

  1. Log in to Plesk
  2. Navigate to Plesk > Docker > Run Container
  3. Type mongo in the Docker catalog search field and select the official one:
  4. Select the Image Version, latest is recommended.
  5. Click Next button to automatically download and configure MongoDB instance deployment.
  6. Disable Automatic port mapping and manually map MongoDB instance to the desired localhost port:

    Note: External port is the port on which all connections to MongoDB will be served.

    Warning: If port mapping is configured, Docker binds to the specified port on all network interfaces of the host system. This means the MongoDB instance will be accessible from anywhere, and additional firewall rules should be created to limit access if necessary.

  7. Map Docker container paths /data/db and /data/configdb to the preferred location on file system to ensure that both data and configuration will survive Docker container restarts and be accessible:

  8. Add the variables MONGO_INITDB_ROOT_USERNAME and MONGO_INITDB_ROOT_PASSWORD to be able to change root password:
  9. Click OK to deploy and start the Docker container
  10. Connect to Plesk server via SSH
  11. Verify that MongoDB is listening for incoming connections:

    # ss -tlpn | grep 27017
    LISTEN 0 4096 :::27017 :::*

  12. Install MongoDB shell:
    • For .deb-based OS (Debian, Ubuntu):

      # apt install -y mongodb-clients

    • For .rpm-based OS (RHEL, CentOS):

      # echo -e '[mongodb-org-4.0]\nname=MongoDB Repository\nbaseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.0/x86_64/\ngpgcheck=1\nenabled=1\ngpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc' >> /etc/yum.repos.d/mongodb.repo

      # yum install -y mongodb-org-shell

  13. Verify MongoDB connectivity from the localhost by running mongo shell on the Plesk server:

    # mongo
    MongoDB shell version: v3.6.8
    connecting to: mongodb://127.0.0.1:27017
    MongoDB server version: 8.0.15
    Welcome to the MongoDB shell.
    For interactive help, type "help".
    For more comprehensive documentation, see
    http://docs.mongodb.org/
    Questions? Try the support group
    http://groups.google.com/group/mongodb-user
    >

Was this article helpful?

Comments

2 comments
Date Votes
  • This is outdated. Ubuntu 22.04 is now supported.
    Please comment on gui

    apt install -y mongodb-clients
    Reading package lists... Done
    Building dependency tree... Done
    Reading state information... Done
    E: Unable to locate package mongodb-clients

    1
  • article is outaded, not working like that

    0

Please sign in to leave a comment.