{"id":3680,"date":"2025-02-20T13:01:56","date_gmt":"2025-02-20T18:01:56","guid":{"rendered":"https:\/\/underhost.com\/blog\/?p=3680"},"modified":"2025-02-20T12:08:59","modified_gmt":"2025-02-20T17:08:59","slug":"install-mongodb-cpanel-server","status":"publish","type":"post","link":"https:\/\/underhost.com\/blog\/install-mongodb-cpanel-server\/","title":{"rendered":"Updated Guide: How to Install MongoDB on a cPanel Server"},"content":{"rendered":"<p>This updated guide walks you through the latest method to install and configure MongoDB on a cPanel server. While cPanel doesn\u2019t natively support MongoDB, you can manually install it for your applications using root access. Follow these steps to ensure a smooth integration.<\/p>\r\n<!-- \/wp:post-content --><!-- Blog Post Content -->\r\n\r\n<!-- wp:paragraph -->\r\n<p>Although cPanel primarily supports MySQL and MariaDB, developers often require MongoDB for NoSQL applications. With the right configuration, you can set up MongoDB on your cPanel server, even though it&#8217;s not officially supported by cPanel.<\/p>\r\n<!-- \/wp:paragraph -->\r\n\r\n<!-- wp:heading -->\r\n<h2>Prerequisites<\/h2>\r\n<!-- \/wp:heading -->\r\n\r\n<!-- wp:list -->\r\n<ul>\r\n<li>Root SSH access to your server<\/li>\r\n<li>cPanel &amp; WHM installed on a CentOS or RHEL-based distribution<\/li>\r\n<li>Basic command-line proficiency<\/li>\r\n<\/ul>\r\n<!-- \/wp:list -->\r\n\r\n<!-- wp:heading -->\r\n<h2>Step 1: Add the MongoDB Repository<\/h2>\r\n<!-- \/wp:heading -->\r\n\r\n<!-- wp:paragraph -->\r\n<p>Begin by creating a MongoDB repository file to ensure you install the latest stable version:<\/p>\r\n<!-- \/wp:paragraph -->\r\n\r\n<!-- wp:code -->\r\n<pre><code># Navigate to the yum repository directory\r\ncd \/etc\/yum.repos.d\/\r\n\r\n# Create and edit the MongoDB repository file\r\nnano mongodb.repo\r\n<\/code><\/pre>\r\n<!-- \/wp:code -->\r\n\r\n<!-- wp:paragraph -->\r\n<p>Add the following content to the file:<\/p>\r\n<!-- \/wp:paragraph -->\r\n\r\n<!-- wp:code -->\r\n<pre><code>[mongodb-org-6.0]\r\nname=MongoDB Repository\r\nbaseurl=https:\/\/repo.mongodb.org\/yum\/redhat\/$releasever\/mongodb-org\/6.0\/x86_64\/\r\ngpgcheck=1\r\nenabled=1\r\ngpgkey=https:\/\/www.mongodb.org\/static\/pgp\/server-6.0.asc\r\n<\/code><\/pre>\r\n<!-- \/wp:code -->\r\n\r\n<!-- wp:paragraph -->\r\n<p>Save and exit the file.<\/p>\r\n<!-- \/wp:paragraph -->\r\n\r\n<!-- wp:heading -->\r\n<h2>Step 2: Install MongoDB<\/h2>\r\n<!-- \/wp:heading -->\r\n\r\n<!-- wp:paragraph -->\r\n<p>Now, install MongoDB using the package manager:<\/p>\r\n<!-- \/wp:paragraph -->\r\n\r\n<!-- wp:code -->\r\n<pre><code># Clean the yum cache\r\nyum clean all\r\n\r\n# Install MongoDB\r\nyum install -y mongodb-org\r\n<\/code><\/pre>\r\n<!-- \/wp:code -->\r\n\r\n<!-- wp:paragraph -->\r\n<p>The installation will include the following key components:<\/p>\r\n<!-- \/wp:paragraph -->\r\n\r\n<!-- wp:list -->\r\n<ul>\r\n<li><code>mongodb-org-server<\/code>: The mongod daemon<\/li>\r\n<li><code>mongodb-org-mongos<\/code>: The mongos daemon<\/li>\r\n<li><code>mongodb-org-shell<\/code>: The MongoDB shell<\/li>\r\n<li><code>mongodb-org-tools<\/code>: Backup and monitoring tools<\/li>\r\n<\/ul>\r\n<!-- \/wp:list -->\r\n\r\n<!-- wp:heading -->\r\n<h2>Step 3: Start and Enable MongoDB<\/h2>\r\n<!-- \/wp:heading -->\r\n\r\n<!-- wp:paragraph -->\r\n<p>Once installed, start MongoDB and configure it to start at boot:<\/p>\r\n<!-- \/wp:paragraph -->\r\n\r\n<!-- wp:code -->\r\n<pre><code># Start MongoDB\r\nsystemctl start mongod\r\n\r\n# Enable MongoDB at startup\r\nsystemctl enable mongod\r\n<\/code><\/pre>\r\n<!-- \/wp:code -->\r\n\r\n<!-- wp:paragraph -->\r\n<p>Check if MongoDB is running:<\/p>\r\n<!-- \/wp:paragraph -->\r\n\r\n<!-- wp:code -->\r\n<pre><code># Verify MongoDB status\r\nsystemctl status mongod\r\n<\/code><\/pre>\r\n<!-- \/wp:code -->\r\n\r\n<!-- wp:heading -->\r\n<h2>Step 4: Install the MongoDB PHP Extension<\/h2>\r\n<!-- \/wp:heading -->\r\n\r\n<!-- wp:paragraph -->\r\n<p>For PHP-based applications, install the MongoDB PHP extension:<\/p>\r\n<!-- \/wp:paragraph -->\r\n\r\n<!-- wp:code -->\r\n<pre><code># Install dependencies\r\nyum install -y php-pear php-devel\r\n\r\n# Install the MongoDB extension\r\npecl install mongodb\r\n<\/code><\/pre>\r\n<!-- \/wp:code -->\r\n\r\n<!-- wp:paragraph -->\r\n<p>Enable the extension by adding it to your PHP configuration:<\/p>\r\n<!-- \/wp:paragraph -->\r\n\r\n<!-- wp:code -->\r\n<pre><code># Enable the MongoDB extension\r\necho \"extension=mongodb.so\" &gt; \/etc\/php.d\/30-mongodb.ini\r\n<\/code><\/pre>\r\n<!-- \/wp:code -->\r\n\r\n<!-- wp:paragraph -->\r\n<p>Restart Apache to apply the changes:<\/p>\r\n<!-- \/wp:paragraph -->\r\n\r\n<!-- wp:code -->\r\n<pre><code># Restart Apache\r\nsystemctl restart httpd\r\n<\/code><\/pre>\r\n<!-- \/wp:code -->\r\n\r\n<!-- wp:heading -->\r\n<h2>Important Considerations<\/h2>\r\n<!-- \/wp:heading -->\r\n\r\n<!-- wp:paragraph -->\r\n<p>Since cPanel does not officially support MongoDB, keep in mind the following:<\/p>\r\n<!-- \/wp:paragraph -->\r\n\r\n<!-- wp:list -->\r\n<ul>\r\n<li>Future cPanel updates might affect MongoDB compatibility.<\/li>\r\n<li>Official cPanel support does not cover MongoDB-related issues.<\/li>\r\n<\/ul>\r\n<!-- \/wp:list -->\r\n\r\n<!-- wp:paragraph -->\r\n<p>For production environments, consider using an external MongoDB service or hosting it separately to avoid conflicts.<\/p>\r\n<!-- \/wp:paragraph -->\r\n\r\n<!-- wp:paragraph -->\r\n<p>For additional support, visit <a href=\"https:\/\/customerpanel.ca\/client\">@CustomerPanel<\/a> or check cPanel\u2019s documentation: <a href=\"https:\/\/support.cpanel.net\/hc\/en-us\/articles\/1500004718862-Can-I-install-MongoDB-on-cPanel\">cPanel MongoDB Support<\/a>.<\/p>\r\n<!-- \/wp:paragraph -->","protected":false},"excerpt":{"rendered":"<p>Updated Guide:<\/strong> Learn how to install MongoDB on a cPanel server with this step-by-step guide. While cPanel does not natively support MongoDB, this updated tutorial provides the latest method to integrate it manually, ensuring compatibility with your web applications.<\/p>\n","protected":false},"author":1,"featured_media":5005,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,11],"tags":[],"class_list":["post-3680","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-controlpanel","category-how-to"],"_links":{"self":[{"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/posts\/3680","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/comments?post=3680"}],"version-history":[{"count":5,"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/posts\/3680\/revisions"}],"predecessor-version":[{"id":5004,"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/posts\/3680\/revisions\/5004"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/media\/5005"}],"wp:attachment":[{"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/media?parent=3680"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/categories?post=3680"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/underhost.com\/blog\/wp-json\/wp\/v2\/tags?post=3680"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}