{"id":1404,"date":"2025-05-20T11:18:49","date_gmt":"2025-05-20T11:18:49","guid":{"rendered":"https:\/\/elyspace.com\/blog\/?p=1404"},"modified":"2025-05-20T11:28:32","modified_gmt":"2025-05-20T11:28:32","slug":"complete-guide-installing-puppeteer-on-cpanel-with-cloudlinux-node-js-selector","status":"publish","type":"post","link":"https:\/\/elyspace.com\/blog\/complete-guide-installing-puppeteer-on-cpanel-with-cloudlinux-node-js-selector\/","title":{"rendered":"Complete Guide: Installing Puppeteer on cPanel with CloudLinux Node.js Selector"},"content":{"rendered":"\n<p><em>By Shahid | May 20, 2025 | 8 min read<\/em><\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/elyspace.com\/blog\/complete-guide-installing-puppeteer-on-cpanel-with-cloudlinux-node-js-selector\/#Introduction\" >Introduction<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/elyspace.com\/blog\/complete-guide-installing-puppeteer-on-cpanel-with-cloudlinux-node-js-selector\/#Prerequisites\" >Prerequisites<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/elyspace.com\/blog\/complete-guide-installing-puppeteer-on-cpanel-with-cloudlinux-node-js-selector\/#Setting_Up_Your_First_Nodejs_Application_If_Needed\" >Setting Up Your First Node.js Application (If Needed)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/elyspace.com\/blog\/complete-guide-installing-puppeteer-on-cpanel-with-cloudlinux-node-js-selector\/#Getting_Started_Accessing_Your_Server\" >Getting Started: Accessing Your Server<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/elyspace.com\/blog\/complete-guide-installing-puppeteer-on-cpanel-with-cloudlinux-node-js-selector\/#Activating_Your_Nodejs_Environment\" >Activating Your Node.js Environment<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/elyspace.com\/blog\/complete-guide-installing-puppeteer-on-cpanel-with-cloudlinux-node-js-selector\/#Verifying_Your_Nodejs_Setup\" >Verifying Your Node.js Setup<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/elyspace.com\/blog\/complete-guide-installing-puppeteer-on-cpanel-with-cloudlinux-node-js-selector\/#Installing_Puppeteer\" >Installing Puppeteer<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/elyspace.com\/blog\/complete-guide-installing-puppeteer-on-cpanel-with-cloudlinux-node-js-selector\/#Confirming_Successful_Installing_Puppeteer_on_cPanel\" >Confirming Successful Installing Puppeteer on cPanel<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/elyspace.com\/blog\/complete-guide-installing-puppeteer-on-cpanel-with-cloudlinux-node-js-selector\/#Creating_Your_First_Puppeteer_Script\" >Creating Your First Puppeteer Script<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/elyspace.com\/blog\/complete-guide-installing-puppeteer-on-cpanel-with-cloudlinux-node-js-selector\/#Running_Your_Test_Script\" >Running Your Test Script<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/elyspace.com\/blog\/complete-guide-installing-puppeteer-on-cpanel-with-cloudlinux-node-js-selector\/#Integrating_Puppeteer_Into_Your_Web_Application\" >Integrating Puppeteer Into Your Web Application<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/elyspace.com\/blog\/complete-guide-installing-puppeteer-on-cpanel-with-cloudlinux-node-js-selector\/#Activating_Your_Enhanced_Application\" >Activating Your Enhanced Application<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/elyspace.com\/blog\/complete-guide-installing-puppeteer-on-cpanel-with-cloudlinux-node-js-selector\/#Testing_Your_New_Puppeteer_Features\" >Testing Your New Puppeteer Features<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/elyspace.com\/blog\/complete-guide-installing-puppeteer-on-cpanel-with-cloudlinux-node-js-selector\/#Troubleshooting_Common_Issues\" >Troubleshooting Common Issues<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/elyspace.com\/blog\/complete-guide-installing-puppeteer-on-cpanel-with-cloudlinux-node-js-selector\/#Browser_Launch_Failures\" >Browser Launch Failures<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-16\" href=\"https:\/\/elyspace.com\/blog\/complete-guide-installing-puppeteer-on-cpanel-with-cloudlinux-node-js-selector\/#Memory_Management\" >Memory Management<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-17\" href=\"https:\/\/elyspace.com\/blog\/complete-guide-installing-puppeteer-on-cpanel-with-cloudlinux-node-js-selector\/#Pro_Tips_for_Daily_Use\" >Pro Tips for Daily Use<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-18\" href=\"https:\/\/elyspace.com\/blog\/complete-guide-installing-puppeteer-on-cpanel-with-cloudlinux-node-js-selector\/#Convenient_Environment_Activation\" >Convenient Environment Activation<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-19\" href=\"https:\/\/elyspace.com\/blog\/complete-guide-installing-puppeteer-on-cpanel-with-cloudlinux-node-js-selector\/#Recommended_Protocols_for_Best_Practices_in_Production\" >Recommended Protocols for Best Practices in Production<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-20\" href=\"https:\/\/elyspace.com\/blog\/complete-guide-installing-puppeteer-on-cpanel-with-cloudlinux-node-js-selector\/#Use_of_Resources\" >Use of Resources<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-21\" href=\"https:\/\/elyspace.com\/blog\/complete-guide-installing-puppeteer-on-cpanel-with-cloudlinux-node-js-selector\/#Application_Stability_and_Reliability\" >Application Stability and Reliability<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-22\" href=\"https:\/\/elyspace.com\/blog\/complete-guide-installing-puppeteer-on-cpanel-with-cloudlinux-node-js-selector\/#Security_Considerations\" >Security Considerations<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-23\" href=\"https:\/\/elyspace.com\/blog\/complete-guide-installing-puppeteer-on-cpanel-with-cloudlinux-node-js-selector\/#Change_Control\" >Change Control<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-24\" href=\"https:\/\/elyspace.com\/blog\/complete-guide-installing-puppeteer-on-cpanel-with-cloudlinux-node-js-selector\/#Abuse_Prevention\" >Abuse Prevention<\/a><\/li><\/ul><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-25\" href=\"https:\/\/elyspace.com\/blog\/complete-guide-installing-puppeteer-on-cpanel-with-cloudlinux-node-js-selector\/#FAQs_About_Puppeteer_on_cPanel\" >FAQs About Puppeteer on cPanel<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-26\" href=\"https:\/\/elyspace.com\/blog\/complete-guide-installing-puppeteer-on-cpanel-with-cloudlinux-node-js-selector\/#Q_How_much_memory_does_Puppeteer_typically_use_on_cPanel\" >Q: How much memory does Puppeteer typically use on cPanel?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-27\" href=\"https:\/\/elyspace.com\/blog\/complete-guide-installing-puppeteer-on-cpanel-with-cloudlinux-node-js-selector\/#Q_Can_I_use_Puppeteer_to_automate_form_submissions_on_websites\" >Q: Can I use Puppeteer to automate form submissions on websites?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-28\" href=\"https:\/\/elyspace.com\/blog\/complete-guide-installing-puppeteer-on-cpanel-with-cloudlinux-node-js-selector\/#Q_Does_Puppeteer_work_with_JavaScript-heavy_single-page_applications\" >Q: Does Puppeteer work with JavaScript-heavy single-page applications?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-29\" href=\"https:\/\/elyspace.com\/blog\/complete-guide-installing-puppeteer-on-cpanel-with-cloudlinux-node-js-selector\/#Q_How_can_I_handle_CAPTCHA_challenges_when_using_Puppeteer\" >Q: How can I handle CAPTCHA challenges when using Puppeteer?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-30\" href=\"https:\/\/elyspace.com\/blog\/complete-guide-installing-puppeteer-on-cpanel-with-cloudlinux-node-js-selector\/#Q_Is_it_possible_to_generate_PDFs_with_Puppeteer_on_cPanel\" >Q: Is it possible to generate PDFs with Puppeteer on cPanel?<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-31\" href=\"https:\/\/elyspace.com\/blog\/complete-guide-installing-puppeteer-on-cpanel-with-cloudlinux-node-js-selector\/#Conclusion\" >Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Introduction\"><\/span>Introduction<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p><strong>Are you looking to automate browser tasks directly from your cPanel hosting?<\/strong> If your goal is to set up browser automation on your cPanel server, then we&#8217;ve got the right guide for you. Using CloudLinux Node.js Selector, we will detail how to configure Puppeteer for taking screenshots, content scraping, and task automation all via your hosting account.<\/p>\n\n\n\n<p>Puppeteer has become the go-to solution for web automation tasks, allowing developers to control headless Chrome or Chromium browsers programmatically. When combined with cPanel and CloudLinux Node.js Selector, you can create powerful web automation solutions directly from your hosting environment.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Prerequisites\"><\/span>Prerequisites<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Before diving into the installation process, ensure you have the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A Node.js Selector enabled cPanel hosting account with CloudLinux<\/li>\n\n\n\n<li>Login credentials to SSH into your hosting account<\/li>\n\n\n\n<li>A preconfigured Node.js Application in cPanel (or follow our steps to set one up)<\/li>\n\n\n\n<li>Basic understanding of JavaScript and Node.js concepts<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Setting_Up_Your_First_Nodejs_Application_If_Needed\"><\/span>Setting Up Your First Node.js Application (If Needed)<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>For those who don&#8217;t have an existing Node.js application on cPanel, complete the following actions:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Access cPanel<\/li>\n\n\n\n<li>Look for the &#8220;Node JS App&#8221; icon in the &#8220;Software&#8221; area<\/li>\n\n\n\n<li>Click on the icon to launch the Node JS selector<\/li>\n\n\n\n<li>Click the &#8220;Add Application&#8221; option<\/li>\n\n\n\n<li>Fill in the details as follows:\n<ul class=\"wp-block-list\">\n<li><strong>Application root<\/strong>: Choose a directory for the app such as <code>\/home\/yourusername\/nodeapp<\/code><\/li>\n\n\n\n<li><strong>App URL<\/strong>: Define the target application URL path<\/li>\n\n\n\n<li><strong>App Start File<\/strong>: Typically it is &#8220;server.js&#8221; or &#8220;app.js&#8221;<\/li>\n\n\n\n<li><strong>Node.js Version<\/strong>: Choose the most relevant stable version (v14 or newer recommended)<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Click on &#8220;Add&#8221; and you will have Node.js ready for use<\/li>\n<\/ol>\n\n\n\n<p>Once your Node.js application is created in cPanel, you&#8217;ll see it listed in the Node.js Selector interface. Now you&#8217;re ready to proceed with Puppeteer installation.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Getting_Started_Accessing_Your_Server\"><\/span>Getting Started: Accessing Your Server<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>First, connect to your server using SSH:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ssh yourusername@your-domain.com\n<\/code><\/pre>\n\n\n\n<p>Once connected, navigate to your Node.js application directory:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd \/home\/yourusername\/yourappfolder\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Activating_Your_Nodejs_Environment\"><\/span>Activating Your Node.js Environment<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>CloudLinux uses virtual environments to isolate Node.js applications. Before working with Node.js, you&#8217;ll need to activate the appropriate environment:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>source \/home\/yourusername\/nodevenv\/yourappname\/version\/bin\/activate\n<\/code><\/pre>\n\n\n\n<p>For example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>source \/home\/yourusername\/nodevenv\/nodeproxy\/19\/bin\/activate\n<\/code><\/pre>\n\n\n\n<p>Your command prompt will change to show you&#8217;re in the activated environment:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;yourappname (version)] &#91;yourusername@server yourappfolder]$\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Verifying_Your_Nodejs_Setup\"><\/span>Verifying Your Node.js Setup<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Ensure Node.js and npm are properly available in your environment:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>node -v\nnpm -v\n<\/code><\/pre>\n\n\n\n<p>You should see version numbers displayed, confirming both tools are ready to use.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Installing_Puppeteer\"><\/span>Installing Puppeteer<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Now, install Puppeteer with a simple npm command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>npm install puppeteer\n<\/code><\/pre>\n\n\n\n<p>This might take several minutes as it downloads Chromium, the browser engine Puppeteer uses to perform its magic. The total size is approximately 170MB depending on your platform.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Confirming_Successful_Installing_Puppeteer_on_cPanel\"><\/span>Confirming Successful Installing Puppeteer on cPanel<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Verify that Puppeteer installed correctly by checking its files:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ls -la ~\/nodevenv\/yourappname\/version\/lib\/node_modules\/puppeteer\n<\/code><\/pre>\n\n\n\n<p>You should see several files and folders, including package.json, lib, and src directories.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Creating_Your_First_Puppeteer_Script\"><\/span>Creating Your First Puppeteer Script<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Let&#8217;s create a test script to ensure everything works:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>nano test-puppeteer.js\n<\/code><\/pre>\n\n\n\n<p>Add this code to your new file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>const puppeteer = require('puppeteer');\n\n(async () =&gt; {\n  console.log('Launching Puppeteer...');\n  try {\n    \/\/ Configure browser with optimized settings for shared hosting\n    const browser = await puppeteer.launch({\n      headless: true,\n      args: &#91;\n        '--no-sandbox',\n        '--disable-setuid-sandbox',\n        '--disable-dev-shm-usage',\n        '--disable-accelerated-2d-canvas',\n        '--disable-gpu'\n      ]\n    });\n    console.log('Browser successfully launched');\n    \n    const page = await browser.newPage();\n    console.log('New page created');\n    \n    await page.goto('https:\/\/example.com');\n    console.log('Page loaded successfully');\n    \n    const title = await page.title();\n    console.log('Page title retrieved:', title);\n    \n    await browser.close();\n    console.log('Browser closed properly');\n  } catch (error) {\n    console.error('Error encountered:', error);\n  }\n})();\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Running_Your_Test_Script\"><\/span>Running Your Test Script<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Execute your script to verify Puppeteer works correctly:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>node test-puppeteer.js\n<\/code><\/pre>\n\n\n\n<p>If successful, you&#8217;ll see a series of log messages showing each step completing properly, similar to:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Launching Puppeteer...\nBrowser successfully launched\nNew page created\nPage loaded successfully\nPage title retrieved: Example Domain\nBrowser closed properly\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Integrating_Puppeteer_Into_Your_Web_Application\"><\/span>Integrating Puppeteer Into Your Web Application<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Now that you&#8217;ve confirmed Puppeteer works, you can integrate it into your main application. Edit your server file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>nano server.js\n<\/code><\/pre>\n\n\n\n<p>Add these powerful Puppeteer-based endpoints to your Express application:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>const express = require('express');\nconst puppeteer = require('puppeteer');\nconst app = express();\n\n\/\/ Your existing code...\n\n\/\/ Screenshot API endpoint\napp.get('\/screenshot', async (req, res) =&gt; {\n  const url = req.query.url;\n  \n  if (!url) {\n    return res.status(400).send('Please provide a URL parameter');\n  }\n  \n  let browser;\n  try {\n    browser = await puppeteer.launch({\n      headless: true,\n      args: &#91;\n        '--no-sandbox',\n        '--disable-setuid-sandbox',\n        '--disable-dev-shm-usage'\n      ]\n    });\n    \n    const page = await browser.newPage();\n    await page.goto(url, { waitUntil: 'networkidle2' });\n    \n    const screenshot = await page.screenshot({ type: 'png' });\n    \n    res.set('Content-Type', 'image\/png');\n    res.send(screenshot);\n  } catch (error) {\n    console.error('Screenshot error:', error);\n    res.status(500).send('Unable to capture screenshot');\n  } finally {\n    if (browser) {\n      await browser.close();\n    }\n  }\n});\n\n\/\/ HTML content renderer endpoint\napp.get('\/render', async (req, res) =&gt; {\n  const url = req.query.url;\n  \n  if (!url) {\n    return res.status(400).send('Please provide a URL parameter');\n  }\n  \n  let browser;\n  try {\n    browser = await puppeteer.launch({\n      headless: true,\n      args: &#91;\n        '--no-sandbox',\n        '--disable-setuid-sandbox',\n        '--disable-dev-shm-usage'\n      ]\n    });\n    \n    const page = await browser.newPage();\n    await page.goto(url, { waitUntil: 'networkidle2' });\n    \n    const content = await page.content();\n    \n    res.set('Content-Type', 'text\/html');\n    res.send(content);\n  } finally {\n    if (browser) {\n      await browser.close();\n    }\n  }\n});\n\n\/\/ Your existing code continues...\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Activating_Your_Enhanced_Application\"><\/span>Activating Your Enhanced Application<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Return to your cPanel Node.js Application Manager and restart your application to apply the changes:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Go to cPanel > Software > Node.js App<\/li>\n\n\n\n<li>Find your application in the list<\/li>\n\n\n\n<li>Click the &#8220;Restart&#8221; button next to your application<\/li>\n\n\n\n<li>Wait for the status to change to &#8220;Running&#8221;<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Testing_Your_New_Puppeteer_Features\"><\/span>Testing Your New Puppeteer Features<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Try accessing your new endpoints with a browser:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>https:&#47;&#47;your-domain.com\/screenshot?url=https:\/\/example.com\nhttps:\/\/your-domain.com\/render?url=https:\/\/example.com\n<\/code><\/pre>\n\n\n\n<p>The first URL will return a PNG screenshot of example.com, while the second will return the fully rendered HTML content.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Troubleshooting_Common_Issues\"><\/span>Troubleshooting Common Issues<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Browser_Launch_Failures\"><\/span>Browser Launch Failures<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>If Chromium doesn&#8217;t launch properly, try using puppeteer-core instead:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>npm uninstall puppeteer\nnpm install puppeteer-core\n<\/code><\/pre>\n\n\n\n<p>Then modify your code to use an existing Chrome installation:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>const puppeteer = require('puppeteer-core');\n\nconst browser = await puppeteer.launch({\n  executablePath: '\/usr\/bin\/google-chrome',  \/\/ Adjust path as needed\n  headless: true,\n  args: &#91;\n    '--no-sandbox',\n    '--disable-setuid-sandbox',\n    '--disable-dev-shm-usage'\n  ]\n});\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Memory_Management\"><\/span>Memory Management<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>For better performance on shared hosting, optimize resource usage:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>const browser = await puppeteer.launch({\n  args: &#91;\n    '--no-sandbox',\n    '--disable-setuid-sandbox',\n    '--disable-dev-shm-usage',\n    '--memory-pressure-off',\n    '--single-process',\n    '--disable-extensions',\n    '--disable-component-extensions-with-background-pages',\n    '--disable-default-apps',\n    '--mute-audio'\n  ]\n});\n<\/code><\/pre>\n\n\n\n<p>Consider implementing a browser pool to reuse browser instances rather than creating new ones for each request. This approach can significantly reduce memory usage and improve response times:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ Simple browser pool implementation\nconst puppeteer = require('puppeteer');\n\nclass BrowserPool {\n  constructor(maxSize = 2) {\n    this.browsers = &#91;];\n    this.maxSize = maxSize;\n    this.inUse = new Set();\n  }\n\n  async getBrowser() {\n    \/\/ Check for available browsers\n    const availableBrowser = this.browsers.find(b =&gt; !this.inUse.has(b));\n    \n    if (availableBrowser) {\n      this.inUse.add(availableBrowser);\n      return availableBrowser;\n    }\n    \n    \/\/ Create new browser if below max size\n    if (this.browsers.length &lt; this.maxSize) {\n      const newBrowser = await puppeteer.launch({\n        headless: true,\n        args: &#91;\n          '--no-sandbox',\n          '--disable-setuid-sandbox',\n          '--disable-dev-shm-usage'\n        ]\n      });\n      \n      this.browsers.push(newBrowser);\n      this.inUse.add(newBrowser);\n      return newBrowser;\n    }\n    \n    \/\/ Wait for a browser to become available\n    return new Promise(resolve =&gt; {\n      const checkInterval = setInterval(() =&gt; {\n        const availableBrowser = this.browsers.find(b =&gt; !this.inUse.has(b));\n        if (availableBrowser) {\n          clearInterval(checkInterval);\n          this.inUse.add(availableBrowser);\n          resolve(availableBrowser);\n        }\n      }, 100);\n    });\n  }\n\n  releaseBrowser(browser) {\n    this.inUse.delete(browser);\n  }\n\n  async closeAll() {\n    await Promise.all(this.browsers.map(browser =&gt; browser.close()));\n    this.browsers = &#91;];\n    this.inUse.clear();\n  }\n}\n\n\/\/ Usage example\nconst pool = new BrowserPool(3);\n\/\/ In your request handler:\nconst browser = await pool.getBrowser();\ntry {\n  \/\/ Use the browser\n} finally {\n  pool.releaseBrowser(browser);\n}\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Pro_Tips_for_Daily_Use\"><\/span>Pro Tips for Daily Use<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Convenient_Environment_Activation\"><\/span>Convenient Environment Activation<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>To avoid manually activating the Node.js environment each time you log in, add this to your .bashrc file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>echo 'source \/home\/yourusername\/nodevenv\/yourappname\/version\/bin\/activate' &gt;&gt; ~\/.bashrc\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Recommended_Protocols_for_Best_Practices_in_Production\"><\/span>Recommended Protocols for Best Practices in Production<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Use_of_Resources\"><\/span>Use of Resources<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Allocate clients with limits on concurrent instances (browser pool) to prevent memory spill over<\/li>\n\n\n\n<li>Use the <code>--single-process<\/code> flag for lower memory usage but be aware this makes Puppeteer less stable<\/li>\n\n\n\n<li>Implement request queuing for high-traffic applications<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Application_Stability_and_Reliability\"><\/span>Application Stability and Reliability<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Ensure the application is responsive by adding timeouts and thorough error catching<\/li>\n\n\n\n<li>Implement health checks to automatically restart browsers that have become unresponsive<\/li>\n\n\n\n<li>Use process managers like PM2 to keep your application running<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Security_Considerations\"><\/span>Security Considerations<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>AVOID security holes by validating URLs prior to using them with Puppeteer<\/li>\n\n\n\n<li>Implement URL whitelisting to prevent access to internal network resources<\/li>\n\n\n\n<li>Sanitize all user inputs to prevent command injection attacks<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Change_Control\"><\/span>Change Control<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Reduce server load by caching frequently fetched content<\/li>\n\n\n\n<li>Implement cache invalidation strategies for dynamic content<\/li>\n\n\n\n<li>Use a CDN for serving generated screenshots when possible<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Abuse_Prevention\"><\/span>Abuse Prevention<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Protect your server from excessive requests by adding rate limits<\/li>\n\n\n\n<li>Implement user authentication for your Puppeteer-powered APIs<\/li>\n\n\n\n<li>Monitor and log all requests to detect abuse patterns<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"FAQs_About_Puppeteer_on_cPanel\"><\/span>FAQs About Puppeteer on cPanel<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Q_How_much_memory_does_Puppeteer_typically_use_on_cPanel\"><\/span>Q: How much memory does Puppeteer typically use on cPanel?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p><strong>A:<\/strong> Each Puppeteer instance with Chromium can use between 200-300MB of RAM, depending on the complexity of the pages being rendered. Using a browser pool can help manage this resource effectively.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Q_Can_I_use_Puppeteer_to_automate_form_submissions_on_websites\"><\/span>Q: Can I use Puppeteer to automate form submissions on websites?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p><strong>A:<\/strong> Yes, Puppeteer provides robust capabilities for form interaction, including filling fields, clicking buttons, and handling authentication. Here&#8217;s a simple example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>await page.type('#username', 'myusername');\nawait page.type('#password', 'mypassword');\nawait page.click('#login-button');\nawait page.waitForNavigation();\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Q_Does_Puppeteer_work_with_JavaScript-heavy_single-page_applications\"><\/span>Q: Does Puppeteer work with JavaScript-heavy single-page applications?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p><strong>A:<\/strong> Absolutely! Puppeteer is particularly well-suited for SPAs as it fully executes JavaScript. Use the <code>waitForSelector<\/code> or <code>waitForFunction<\/code> methods to ensure the page has loaded completely before interacting with elements.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Q_How_can_I_handle_CAPTCHA_challenges_when_using_Puppeteer\"><\/span>Q: How can I handle CAPTCHA challenges when using Puppeteer?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p><strong>A:<\/strong> For legitimate use cases, consider:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Using CAPTCHA solving services via their APIs<\/li>\n\n\n\n<li>Implementing manual intervention for critical flows<\/li>\n\n\n\n<li>Requesting API access from the target website when possible<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Q_Is_it_possible_to_generate_PDFs_with_Puppeteer_on_cPanel\"><\/span>Q: Is it possible to generate PDFs with Puppeteer on cPanel?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p><strong>A:<\/strong> Yes, use the <code>page.pdf()<\/code> method:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>const pdf = await page.pdf({\n  format: 'A4',\n  printBackground: true,\n  margin: {\n    top: '1cm',\n    right: '1cm',\n    bottom: '1cm',\n    left: '1cm'\n  }\n});\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Installation guide for the Puppetter By using this elaborate guide, you are ready to have Puppeteer up and running on your cPanel server. You can now automate your browser (take screenshots, extract content, perform web testing, etc.) directly from your web hosting.<\/p>\n\n\n\n<p>Puppeteer combined with Node.js and CloudLinux makes a great combination to easily develop advanced web automation solutions without needing dedicated server resources. From taking simple screenshots to performing complex web scraping, the possiblities are now endless with Puppeteer on cPanel.<\/p>\n\n\n\n<p>Do remember to implement the best practices according to the guide, especially when it comes to efficient resource management and security, so you can Puppeteer functionality remains performant and secure in a production environment.<\/p>\n\n\n\n<p><em>Have you implemented Puppeteer on your cPanel server? Share your experience or questions in the comments below!<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>By Shahid | May 20, 2025 | 8 min read Introduction Are you looking to automate browser tasks directly from your cPanel hosting? If your goal is to set up browser automation on your cPanel server, then we&#8217;ve got the right guide for you. Using CloudLinux Node.js Selector, we will detail how to configure Puppeteer [&hellip;]<\/p>\n","protected":false},"author":6,"featured_media":1406,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"two_page_speed":[],"footnotes":""},"categories":[6,18],"tags":[46,47,45,44,48],"class_list":["post-1404","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","category-hosting-management","tag-cloudlinux-automation","tag-eadless-chrome-cpanel","tag-node-js-selector","tag-puppeteer-cpanel","tag-puppeteer-installation-guide"],"acf":[],"_links":{"self":[{"href":"https:\/\/elyspace.com\/blog\/wp-json\/wp\/v2\/posts\/1404","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/elyspace.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/elyspace.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/elyspace.com\/blog\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/elyspace.com\/blog\/wp-json\/wp\/v2\/comments?post=1404"}],"version-history":[{"count":3,"href":"https:\/\/elyspace.com\/blog\/wp-json\/wp\/v2\/posts\/1404\/revisions"}],"predecessor-version":[{"id":1411,"href":"https:\/\/elyspace.com\/blog\/wp-json\/wp\/v2\/posts\/1404\/revisions\/1411"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/elyspace.com\/blog\/wp-json\/wp\/v2\/media\/1406"}],"wp:attachment":[{"href":"https:\/\/elyspace.com\/blog\/wp-json\/wp\/v2\/media?parent=1404"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/elyspace.com\/blog\/wp-json\/wp\/v2\/categories?post=1404"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/elyspace.com\/blog\/wp-json\/wp\/v2\/tags?post=1404"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}