<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>#cPanelHosting &#8211; Aveshost Blog</title>
	<atom:link href="https://blog.aveshost.com/tag/cpanelhosting/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.aveshost.com</link>
	<description>Your Blueprint for Online Success</description>
	<lastBuildDate>Fri, 02 Jan 2026 22:49:26 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1</generator>

<image>
	<url>https://blog.aveshost.com/wp-content/uploads/2026/01/logo-150x150.png</url>
	<title>#cPanelHosting &#8211; Aveshost Blog</title>
	<link>https://blog.aveshost.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How to Deploy Angular App on cPanel: CSR &#038; SSR Guide</title>
		<link>https://blog.aveshost.com/how-to-deploy-angular-app-on-cpanel/</link>
					<comments>https://blog.aveshost.com/how-to-deploy-angular-app-on-cpanel/#respond</comments>
		
		<dc:creator><![CDATA[James Wilson]]></dc:creator>
		<pubDate>Thu, 27 Feb 2025 20:11:51 +0000</pubDate>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[#Angular]]></category>
		<category><![CDATA[#AngularDeployment]]></category>
		<category><![CDATA[#AngularSSR]]></category>
		<category><![CDATA[#cPanelHosting]]></category>
		<category><![CDATA[#DeployAngular]]></category>
		<category><![CDATA[#FrontendDevelopment]]></category>
		<category><![CDATA[#HostAngularApp]]></category>
		<category><![CDATA[#WebDevelopment]]></category>
		<guid isPermaLink="false">https://blog.aveshost.com/?p=3126</guid>

					<description><![CDATA[How to deploy Angular applications on cPanel through client-side rendering (CSR) or server-side rendering (SSR) To deploy Angular app on cPanel may seem challenging at first, but once you understand the process, it becomes straightforward and easy to manage! If you&#8217;re an Angular developer looking to deploy your application on a cPanel hosting environment, you&#8217;ve [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading" id="how-to-deploy-angular-applications-on-c-panel-through-client-side-rendering-csr-or-server-side-rendering-ssr">How to deploy Angular applications on cPanel through client-side rendering (CSR) or server-side rendering (SSR)</h2>



<p class="wp-block-paragraph">To deploy Angular app on cPanel may seem challenging at first, but once you understand the process, it becomes straightforward and easy to manage!</p>



<p class="wp-block-paragraph">If you&#8217;re an Angular developer looking to deploy your application on a cPanel hosting environment, you&#8217;ve come to the right place. Many shared hosting providers like <a href="https://www.aveshost.com/" rel="noopener">Aveshost</a> use <a href="https://blog.aveshost.com/how-to-buy-cpanel-hosting/">cPanel</a>, making it a convenient and budget-friendly option for deploying Angular apps. </p>



<p class="wp-block-paragraph">However, setting up an Angular app on cPanel requires understanding how to configure both client-side and server-side deployments properly.</p>



<div class="wp-block-rank-math-toc-block" id="rank-math-toc"><h2>Table of Contents</h2><nav><div><div><a href="#how-to-deploy-angular-applications-on-c-panel-through-client-side-rendering-csr-or-server-side-rendering-ssr">How to deploy Angular applications on cPanel through client-side rendering (CSR) or server-side rendering (SSR)</a></div><div><a href="#&#x1f4cc;-prerequisites"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4cc.png" alt="📌" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Prerequisites</a></div><div><a href="#understanding-the-basics-client-side-vs-server-side-rendering">Understanding the Basics: Client-Side vs. Server-Side Rendering</a></div><div><a href="#crucial-node-js-version-synchronization">Crucial Node.js Version Synchronization</a></div><div><a href="#how-to-deploy-angular-app-on-c-panel-client-side-rendering-csr">How to deploy Angular app on cPanel: Client-side rendering (CSR)</a></div><div><a href="#angular-universal-deployment-angular-v-16-and-below-combining-ssr-and-prerendering-on-c-panel">Angular Universal Deployment (Angular v16 and below): Combining SSR and Prerendering on cPanel</a></div><div><a href="#angular-v-17-v-18-v-19-ssr-and-prerendering-deployment-on-c-panel">Angular v17, v18, v19: SSR and Prerendering Deployment on cPanel</a></div><div><a href="#troubleshooting-tips">Troubleshooting Tips</a></div><div><a href="#conclusion">Conclusion</a></div><div><a href="#frequently-asked-questions-fa-qs">Frequently Asked Questions (FAQs)</a></div></div></nav></div>



<p class="wp-block-paragraph">In this guide, we’ll walk you through everything you need to know about deploying an Angular app on cPanel. We’ll cover both client-side rendering (CSR) and server-side rendering (SSR) using Angular Universal for Angular versions 16 and earlier, and the new Angular SSR for Angular v17, v18, and v19.</p>



<h2 class="wp-block-heading" id="&#x1f4cc;-prerequisites"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f4cc.png" alt="📌" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Prerequisites</h2>



<p class="wp-block-paragraph">Before we begin, make sure you have:</p>



<ul class="wp-block-list">
<li>A cPanel hosting account: If you don’t have <a href="https://www.aveshost.com/web-hosting" rel="noopener">cPanel hosting</a>, follow this guide to purchase one: “<a href="https://blog.aveshost.com/how-to-buy-cpanel-hosting/">How to Buy cPanel Hosting</a>”</li>



<li>A <a href="https://www.aveshost.com/domains" rel="noopener">domain</a> or subdomain set up</li>



<li>Angular installed on your local machine</li>



<li>FTP or cPanel File Manager access</li>



<li>Basic knowledge of Angular CLI and hosting environments</li>
</ul>



<h2 class="wp-block-heading" id="understanding-the-basics-client-side-vs-server-side-rendering">Understanding the Basics: Client-Side vs. Server-Side Rendering</h2>



<p class="wp-block-paragraph">Before diving into the deployment process, let&#8217;s briefly touch on the difference between client-side rendering (CSR) and server-side rendering (SSR).</p>



<ul class="wp-block-list">
<li><strong>Client-Side Rendering (CSR):</strong> In CSR, the browser downloads a minimal HTML file and then executes JavaScript to render the application. This is the default behavior for Angular.</li>



<li><strong>Server-Side Rendering (SSR):</strong> With SSR, the server pre-renders the application and sends the fully rendered HTML to the browser. This improves initial load times and SEO.</li>
</ul>



<h2 class="wp-block-heading" id="crucial-node-js-version-synchronization">Crucial Node.js Version Synchronization</h2>



<p class="wp-block-paragraph">Before you start building and deploying, a critical step is ensuring your Node.js versions align. Discrepancies here can lead to frustrating and hard-to-debug issues.</p>



<ul class="wp-block-list">
<li><strong>Checking cPanel&#8217;s Node.js Version:</strong>
<ul class="wp-block-list">
<li>Navigate to &#8220;Setup Node.js App&#8221; within your cPanel.</li>



<li>Click on &#8220;+CREATE APPLICATION&#8221; (you don&#8217;t have to fully create one).</li>



<li>Locate the &#8220;Node.js version&#8221; dropdown menu.</li>



<li>Note the version displayed. This is the Node.js version your cPanel environment is using.</li>
</ul>
</li>



<li><strong>Matching Your Local Node.js Version:</strong>
<ul class="wp-block-list">
<li>It&#8217;s imperative that the Node.js version on your local development machine matches the one on your cPanel server.</li>



<li>If you find a mismatch, adjust your local Node.js version accordingly.</li>



<li><strong>Using Node Version Manager (nvm):</strong>
<ul class="wp-block-list">
<li>For <a href="https://github.com/coreybutler/nvm-windows" target="_blank" rel="noreferrer noopener">Windows OS</a>, <a href="https://github.com/nvm-sh/nvm?tab=readme-ov-file#installing-and-updating" target="_blank" rel="noreferrer noopener nofollow">macOS</a>, and <a href="https://github.com/nvm-sh/nvm?tab=readme-ov-file#installing-and-updating" target="_blank" rel="noreferrer noopener nofollow">Linux</a> users, the Node Version Manager (nvm) is highly recommended. It allows you to easily switch between different Node.js versions.</li>



<li>If you don&#8217;t have nvm, you can find installation instructions by searching for &#8220;nvm install&#8221; and your operating system.</li>



<li>After installing NVM, you can install the required node version by typing <code>nvm install &lt;version number&gt;</code>. For example <code>nvm install 18</code>.</li>



<li>Then to use that version you can type <code>nvm use &lt;version number&gt;</code>. For example <code>nvm use 18</code>.</li>
</ul>
</li>



<li>Once you have the correct version installed and being used, run <code>node -v</code> in your terminal to verify that the correct version is active.</li>
</ul>
</li>



<li><strong>Build After Verification:</strong>
<ul class="wp-block-list">
<li>After confirming that your local Node.js version matches cPanel&#8217;s, thoroughly test your Angular application locally to ensure it functions correctly.</li>



<li>Once you have verified that your application is working correctly, then and only then should you build your angular application for deployment.</li>
</ul>
</li>
</ul>



<p class="wp-block-paragraph">By ensuring Node.js version consistency, you&#8217;ll significantly reduce the likelihood of deployment-related errors and streamline the process.</p>



<h2 class="wp-block-heading" id="how-to-deploy-angular-app-on-c-panel-client-side-rendering-csr">How to deploy Angular app on cPanel: Client-side rendering (CSR)</h2>



<p class="wp-block-paragraph">A client-side Angular app is a static web application that doesn’t require a backend server. It’s essentially a collection of HTML, CSS, and JavaScript files served via a web server.</p>



<h3 class="wp-block-heading" id="step-1-build-the-angular-app-production-build">Step 1: Build the Angular App: Production Build</h3>



<p class="wp-block-paragraph">First, navigate to your Angular project folder and run:</p>



<pre class="wp-block-code"><code>ng build   <em>OR </em>
ng build --configuration=production</code></pre>



<p class="wp-block-paragraph">This command generates a new <strong>dist</strong> folder in your project root, containing the <strong>browser</strong> directory with the compiled build files of your application.</p>



<p class="wp-block-paragraph">Make sure there are no errors during the build process; any issues must be resolved before proceeding.</p>



<p class="wp-block-paragraph">Additionally, the default build path (<strong>dist </strong>and its subfolder) can be customized in the <strong>angular.json</strong> file under the following option:</p>



<pre class="wp-block-code"><code>"options": {
  "outputPath": "dist/your-app-name"
}</code></pre>



<h3 class="wp-block-heading" id="step-2-upload-to-c-panel">Step 2: Upload to cPanel</h3>



<p class="wp-block-paragraph">Upload the content of the&nbsp;<strong>browser</strong>&nbsp;folder from the&nbsp;<strong>dist</strong>&nbsp;folder to your cPanel. </p>



<p class="wp-block-paragraph">In your <code>dist/your-app-name</code> folder, zip the <em>contents</em> of the <code>browser</code> folder, not the <code>browser</code> folder itself. This is because you want the files inside the <code>browser</code> folder to be directly in your <code>public_html</code> (or your chosen subdirectory) after unzipping.</p>



<p class="wp-block-paragraph">Learn more about&nbsp;<a href="https://blog.aveshost.com/how-to-upload-your-website/">how to upload your website files</a>&nbsp;via File Manager or FTP.</p>



<h4 class="wp-block-heading" id="using-c-panel-file-manager">Using cPanel File Manager</h4>



<ol start="1" class="wp-block-list">
<li>Log in to your cPanel.</li>



<li>Navigate to <strong>File Manager</strong> &gt; <strong>public_html</strong> (or your <a href="https://my.aveshost.com/knowledgebase/19/How-to-Create-a-Subdomain-in-cPanel.html" rel="noopener">subdomain</a> directory). </li>



<li>Click <strong>Upload</strong>, then select zip file from the <code>dist/your-app-name/browser</code> folder.</li>



<li>Once uploaded, extract the zip file.</li>
</ol>



<p class="wp-block-paragraph">Ensure that all files are located in the <strong>public_html</strong> folder. If they are not, navigate to the folder where they are stored, select all files, and move them to the <strong>public_html</strong> folder or your chosen subdomain directory.</p>



<h3 class="wp-block-heading" id="step-3-configure-htaccess-for-angular-routing">Step 3: Configure .htaccess for Angular Routing</h3>



<p class="wp-block-paragraph">Angular uses client-side routing, so direct URL navigation might not work without configuring <code>.htaccess</code>. </p>



<ol class="wp-block-list">
<li>To view hidden files (such as .htaccess), click on&nbsp;<strong>Settings</strong>&nbsp;in the top-right corner and enable&nbsp;<strong>Show Hidden Files (dotfiles)</strong>.</li>
</ol>



<figure class="wp-block-image size-large"><img fetchpriority="high" decoding="async" width="1024" height="108" src="https://blog.aveshost.com/wp-content/uploads/2025/02/Deploy-Angular-app-on-cPanel-show-hidden-files-1024x108.png" alt="Deploy Angular app on cPanel - show hidden files" class="wp-image-3127" srcset="https://blog.aveshost.com/wp-content/uploads/2025/02/Deploy-Angular-app-on-cPanel-show-hidden-files-1024x108.png 1024w, https://blog.aveshost.com/wp-content/uploads/2025/02/Deploy-Angular-app-on-cPanel-show-hidden-files-300x32.png 300w, https://blog.aveshost.com/wp-content/uploads/2025/02/Deploy-Angular-app-on-cPanel-show-hidden-files-768x81.png 768w, https://blog.aveshost.com/wp-content/uploads/2025/02/Deploy-Angular-app-on-cPanel-show-hidden-files-1536x162.png 1536w, https://blog.aveshost.com/wp-content/uploads/2025/02/Deploy-Angular-app-on-cPanel-show-hidden-files-2048x215.png 2048w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<ol start="2" class="wp-block-list">
<li>Create a <code>.htaccess</code> file inside <code>public_html</code> and add:</li>
</ol>



<pre class="wp-block-code"><code>RewriteEngine On
RewriteBase /
RewriteRule ^index.html$ - &#91;L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule . /index.html &#91;L]</code></pre>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="159" src="https://blog.aveshost.com/wp-content/uploads/2025/02/Deploy-Angular-app-on-cPanel-editing-htaccess-1024x159.png" alt="Deploy Angular app on cPanel - editing htaccess" class="wp-image-3131" srcset="https://blog.aveshost.com/wp-content/uploads/2025/02/Deploy-Angular-app-on-cPanel-editing-htaccess-1024x159.png 1024w, https://blog.aveshost.com/wp-content/uploads/2025/02/Deploy-Angular-app-on-cPanel-editing-htaccess-300x47.png 300w, https://blog.aveshost.com/wp-content/uploads/2025/02/Deploy-Angular-app-on-cPanel-editing-htaccess-768x119.png 768w, https://blog.aveshost.com/wp-content/uploads/2025/02/Deploy-Angular-app-on-cPanel-editing-htaccess-1536x239.png 1536w, https://blog.aveshost.com/wp-content/uploads/2025/02/Deploy-Angular-app-on-cPanel-editing-htaccess-2048x319.png 2048w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph">This ensures that Angular’s routing works correctly without 404 errors.</p>



<h3 class="wp-block-heading" id="step-4-test-your-deployment">Step 4: Test Your Deployment</h3>



<p class="wp-block-paragraph">Open your domain in a browser and ensure everything works smoothly. If you see a blank page, check the console for errors and verify that the <code>base-href</code> in <code>index.html</code> is correctly set:</p>



<pre class="wp-block-code"><code>&lt;base href="/"&gt;</code></pre>



<h2 class="wp-block-heading" id="angular-universal-deployment-angular-v-16-and-below-combining-ssr-and-prerendering-on-c-panel">Angular Universal Deployment (Angular v16 and below): Combining SSR and Prerendering on cPanel</h2>



<p class="wp-block-paragraph">Server-side rendering (SSR) improves SEO, performance, and initial load time. For <strong>Angular v16, v15, v14, v13, v12</strong> and earlier, Angular Universal is required for Server-Side Rendering (SSR). If you haven&#8217;t installed Angular Universal yet, follow Step 1. Otherwise, proceed to Step 2.</p>



<h3 class="wp-block-heading" id="step-1-add-angular-universal-to-your-project">Step 1: Add Angular Universal to Your Project</h3>



<pre class="wp-block-code"><code>ng add @nguniversal/express-engine</code></pre>



<p class="wp-block-paragraph">This sets up an Express server to handle SSR.</p>



<h3 class="wp-block-heading" id="step-2-modify-the-server-ts-file">Step 2:&nbsp;Modify the server.ts file</h3>



<p class="wp-block-paragraph">First, replace this code in the&nbsp;<strong>server.ts</strong>&nbsp;file:</p>



<pre class="wp-block-code"><code>function run(): void {
const port = process.env&#91;'PORT'] || 4000;

// Start up the Node server
const server = app();
server.listen(port, () =&gt; {
console.log(`Node Express server listening on http://localhost:${port}`);
});
}</code></pre>



<p class="wp-block-paragraph">With the new code:</p>



<pre class="wp-block-code"><code>function isRunningOnApachePassenger(): boolean {
return moduleFilename.includes('lsnode.js');
}

function run(): void {
// Start up the Node server
const server = app();

if (isRunningOnApachePassenger()) {
server.listen(() =&gt; {
console.log('Node Express listening to Passenger Apache');
});
return;
}

const port = process.env&#91;'PORT'] || 4000;

server.listen(port, () =&gt; {
console.log(`Node Express server listening on http://localhost:${port}`);
});
}</code></pre>



<p class="wp-block-paragraph">Second, replace:</p>



<pre class="wp-block-code"><code>if (
moduleFilename === __filename ||
moduleFilename.includes('iisnode')
)</code></pre>



<p class="wp-block-paragraph">With this code:</p>



<pre class="wp-block-code"><code>if (
moduleFilename === __filename ||
moduleFilename.includes('iisnode') ||
isRunningOnApachePassenger()
)</code></pre>



<h3 class="wp-block-heading" id="step-3-building-your-angular-universal-application">Step 3:&nbsp;Building your Angular Universal Application</h3>



<p class="wp-block-paragraph">You can customize the output directories for your browser and server builds (within <code>dist</code>) by modifying the <code>angular.json</code> configuration file:</p>



<pre class="wp-block-code"><code>"options": {
"outputPath": "dist/your-app-name",
}</code></pre>



<h4 class="wp-block-heading" id="build-the-app">Build the App</h4>



<pre class="wp-block-code"><code>npm run build:ssr</code></pre>



<p class="wp-block-paragraph">Verify that the build process completes without errors. Resolve any errors before proceeding.</p>



<p class="wp-block-paragraph">This generates <code>dist/<code>your-app-name/</code>server</code> and <code>dist/<code>your-app-name/</code>browser</code> folders.</p>



<h3 class="wp-block-heading" id="step-4-preparing-your-project-for-deployment">Step 4: Preparing Your Project for Deployment</h3>



<ol class="wp-block-list">
<li>On your local machine, navigate to your Angular project folder.</li>



<li>Enable visibility for any hidden files (if necessary).</li>



<li>To optimize your deployment package, it&#8217;s essential to exclude certain files and folders:
<ul class="wp-block-list">
<li><code>node_modules</code>: This folder contains your project&#8217;s dependencies and is typically very large. We&#8217;ll install these dependencies on the server later.</li>



<li><code>.git</code>: This folder contains your project&#8217;s Git repository and is not needed for deployment.</li>



<li><code>README.md</code> and <code>.gitignore</code>: These are development-related files and are not required on the production server.</li>
</ul>
</li>



<li>Select all the remaining files and folders in your Angular project folder.</li>



<li>Create a ZIP archive of the selected files. </li>
</ol>



<h3 class="wp-block-heading" id="step-5-upload-the-archive-file-to-c-panel">Step 5: Upload the archive file&nbsp;to cPanel</h3>



<ol class="wp-block-list">
<li>In your cPanel, go to <strong>File Manager</strong> and create a folder outside the <strong>public_html</strong> directory (e.g., <strong>app</strong>).</li>
</ol>



<figure class="wp-block-image size-large is-resized"><img decoding="async" width="1024" height="452" src="https://blog.aveshost.com/wp-content/uploads/2025/02/Deploy-Angular-app-on-cPanel-App-folder-1024x452.png" alt="Deploy Angular app on cPanel - App folder" class="wp-image-3134" style="width:759px;height:auto" srcset="https://blog.aveshost.com/wp-content/uploads/2025/02/Deploy-Angular-app-on-cPanel-App-folder-1024x452.png 1024w, https://blog.aveshost.com/wp-content/uploads/2025/02/Deploy-Angular-app-on-cPanel-App-folder-300x132.png 300w, https://blog.aveshost.com/wp-content/uploads/2025/02/Deploy-Angular-app-on-cPanel-App-folder-768x339.png 768w, https://blog.aveshost.com/wp-content/uploads/2025/02/Deploy-Angular-app-on-cPanel-App-folder.png 1165w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph"><em><strong>NOTE:</strong> You cannot directly configure a Node.js application within the <code>public_html</code> folder of your main domain. Node.js applications require a dedicated, separate directory outside of <code>public_html</code></em></p>



<ol start="2" class="wp-block-list">
<li>Within the just created App folder, select &#8216;<strong>Upload</strong>&#8216; from the top menu.</li>



<li>Click the &#8216;<strong>Select File</strong>&#8216; button to locate and select the ZIP archive you created on your local machine. The upload process will start as soon as you select the file.</li>



<li>Once the upload is complete, return to the directory where you uploaded the ZIP archive.</li>



<li>Right-click the uploaded ZIP file and select &#8216;<strong>Extract</strong>&#8216; to unzip it.</li>
</ol>



<p class="wp-block-paragraph">Ensure that all files are located in the <strong>App</strong> folder. If they are not, navigate to the extracted folder, select all files, and move them to the <strong>App</strong> folder or your chosen directory.</p>



<p class="wp-block-paragraph">Learn&nbsp;<a href="https://blog.aveshost.com/how-to-upload-your-website/">how to upload your website files</a>&nbsp;via File Manager or FTP.</p>



<h3 class="wp-block-heading" id="step-6-set-up-a-node-js-application-in-c-panel">Step 6: Set Up a Node.js Application in cPanel</h3>



<ul class="wp-block-list">
<li>In the cPanel, Scroll down to the&nbsp;<strong>Software</strong>&nbsp;section.</li>



<li>Click&nbsp;<strong>Setup Node.js App</strong>.</li>



<li>Click + <strong>Create Application</strong>.</li>



<li>Node.js version selection: It&#8217;s critical to select the Node.js version that matches the one you used for local development. This ensures compatibility and avoids potential runtime errors.</li>



<li>Application mode: Select <strong>Production.</strong></li>



<li>Application root: Type <strong>app </strong>or your chosen directory</li>



<li>Application URL: Choose your domain name.</li>



<li>Application startup file: <code>dist/your-app-name/server/main.js</code></li>
</ul>



<p class="wp-block-paragraph"><em>If you have any environment variables, you can add them from your <code>.env or .env.local file.</code></em></p>



<figure class="wp-block-image size-large"><img decoding="async" src="https://blog.aveshost.com/wp-content/uploads/2025/02/Deploy-Angular-app-on-cPanel-Nodejs-app-setup-1024x439.png" alt="Deploy Angular app on cPanel - Node.js app setup" class="wp-image-3136"/></figure>



<ul class="wp-block-list">
<li>Click on <strong>CREATE</strong> to create the Node.js application.</li>



<li>Stop the app. Then, go to &#8216;Detected Configuration Files&#8217;. If <code>package.json</code> doesn&#8217;t appear, refresh the page.</li>



<li>Click “<strong>Run NPM Install</strong>” to install the dependencies specified in your&nbsp;<code>package.json</code>&nbsp;file.</li>
</ul>



<p class="wp-block-paragraph"><strong>Note:</strong> You can also use the Terminal to install dependencies. Simply return to your cPanel dashboard or search for &#8220;Terminal&#8221; in the top search bar.</p>



<p class="wp-block-paragraph"><em>Activate the Node.js environment. Click to copy the provided command at the top and execute it in the terminal.&nbsp;</em></p>



<pre class="wp-block-code"><code>source /home/username/nodevenv/app/20/bin/activate &amp;&amp; cd /home/username/app
Example: source /home/username/nodevenv/app/20/bin/activate &amp;&amp; cd /home/username/app</code></pre>



<p class="wp-block-paragraph"><em>(Replace&nbsp;<code>20</code>&nbsp;with your selected Node.js version.)</em></p>



<p class="wp-block-paragraph">Once the Node.js environment is activated, run the <code>npm install</code> command. </p>



<p class="wp-block-paragraph"><strong>Note:</strong> You don’t need to run the <code>npm install</code> command again in the Terminal if <strong>&#8220;Run NPM Install&#8221;</strong> was successfully executed earlier.</p>



<ul class="wp-block-list">
<li>Restart the application by clicking the &#8216;<strong>START APP</strong>&#8216; button.</li>
</ul>



<p class="wp-block-paragraph">Open a new browser tab and navigate to your website&#8217;s URL. You should now see your Angular Universal application successfully running. </p>



<p class="wp-block-paragraph">Congratulations! You&#8217;ve successfully deployed your Angular Universal application on cPanel.</p>



<h2 class="wp-block-heading" id="angular-v-17-v-18-v-19-ssr-and-prerendering-deployment-on-c-panel">Angular v17, v18, v19: SSR and Prerendering Deployment on cPanel</h2>



<p class="wp-block-paragraph">To deploy Angular on cPanel, Angular 17+ introduced a more streamlined SSR setup, removing the need for Angular Universal. Here’s how to deploy it on cPanel:</p>



<p class="wp-block-paragraph">If you haven&#8217;t set up Angular&#8217;s new SSR, follow Step 1. If you&#8217;ve already added <code>@angular/ssr</code>, proceed to Step 2.</p>



<h3 class="wp-block-heading" id="step-1-add-angulars-new-ssr-to-your-project">Step 1: Add Angular&#8217;s New SSR to Your Project</h3>



<pre class="wp-block-code"><code>ng add @angular/ssr</code></pre>



<h3 class="wp-block-heading" id="step-2-build-your-ssr-app">Step 2: Build Your SSR App</h3>



<p class="wp-block-paragraph">You can customize the output directories for your browser and server builds (within <code>dist</code>) by modifying the <code>angular.json</code> configuration file:</p>



<pre class="wp-block-code"><code>"options": {
"outputPath": "dist/your-app-name",
}</code></pre>



<h4 class="wp-block-heading" id="to-build-an-angular-v-17-application">To build an Angular v17+ application:</h4>



<ol class="wp-block-list">
<li>In your terminal, navigate to the folder containing your Angular project.</li>



<li>Run the build command:</li>
</ol>



<pre class="wp-block-code"><code>ng build</code></pre>



<ol start="3" class="wp-block-list">
<li>Verify that the build process completes without errors. Resolve any errors before proceeding.</li>
</ol>



<p class="wp-block-paragraph"><em>This command builds your Angular application, generating output files organized into <code>browser</code> and <code>server</code> directories. The <code>browser</code> directory contains client-side files, and the <code>server</code> directory contains server-side files.</em></p>



<h3 class="wp-block-heading" id="step-3-preparing-your-project-for-deployment">Step 3: Preparing Your Project for Deployment</h3>



<ol class="wp-block-list">
<li>On your local machine, navigate to your Angular project folder.</li>



<li>Enable visibility for any hidden files (if necessary).</li>



<li>To optimize your deployment package, it&#8217;s essential to exclude certain files and folders:
<ul class="wp-block-list">
<li><code>node_modules</code>: This folder contains your project&#8217;s dependencies and is typically very large. We&#8217;ll install these dependencies on the server later.</li>



<li><code>.git</code>: This folder contains your project&#8217;s Git repository and is not needed for deployment.</li>



<li><code>README.md</code> and <code>.gitignore</code>: These are development-related files and are not required on the production server.</li>
</ul>
</li>



<li>Select all the remaining files and folders in your Angular project folder.</li>



<li>Create a ZIP archive of the selected files. </li>
</ol>



<h3 class="wp-block-heading" id="step-4-upload-the-archive-file-to-c-panel">Step 4: Upload the archive file&nbsp;to cPanel</h3>



<ol class="wp-block-list">
<li>In your cPanel, go to <strong>File Manager</strong> and create a folder outside the <strong>public_html</strong> directory (e.g., <strong>app</strong>).</li>
</ol>



<figure class="wp-block-image size-large is-resized"><img decoding="async" width="1024" height="452" src="https://blog.aveshost.com/wp-content/uploads/2025/02/Deploy-Angular-app-on-cPanel-App-folder-1024x452.png" alt="Deploy Angular app on cPanel - App folder" class="wp-image-3134" style="width:759px;height:auto" srcset="https://blog.aveshost.com/wp-content/uploads/2025/02/Deploy-Angular-app-on-cPanel-App-folder-1024x452.png 1024w, https://blog.aveshost.com/wp-content/uploads/2025/02/Deploy-Angular-app-on-cPanel-App-folder-300x132.png 300w, https://blog.aveshost.com/wp-content/uploads/2025/02/Deploy-Angular-app-on-cPanel-App-folder-768x339.png 768w, https://blog.aveshost.com/wp-content/uploads/2025/02/Deploy-Angular-app-on-cPanel-App-folder.png 1165w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph"><em><strong>NOTE:</strong> You cannot directly configure a Node.js application within the <code>public_html</code> folder of your main domain. Node.js applications require a dedicated, separate directory outside of <code>public_html</code></em></p>



<ol start="2" class="wp-block-list">
<li>Within the just created App folder, select &#8216;<strong>Upload</strong>&#8216; from the top menu.</li>



<li>Click the &#8216;<strong>Select File</strong>&#8216; button to locate and select the ZIP archive you created on your local machine. The upload process will start as soon as you select the file.</li>



<li>Once the upload is complete, return to the directory where you uploaded the ZIP archive.</li>



<li>Right-click the uploaded ZIP file and select &#8216;<strong>Extract</strong>&#8216; to unzip it.</li>
</ol>



<p class="wp-block-paragraph">Ensure that all files are located in the <strong>App</strong> folder. If they are not, navigate to the extracted folder, select all files, and move them to the <strong>App</strong> folder or your chosen directory.</p>



<p class="wp-block-paragraph">Learn&nbsp;<a href="https://blog.aveshost.com/how-to-upload-your-website/">how to upload your website files</a>&nbsp;via File Manager or FTP.</p>



<h3 class="wp-block-heading" id="step-5-set-up-a-node-js-application-in-c-panel">Step 5: Set Up a Node.js Application in cPanel</h3>



<ul class="wp-block-list">
<li>In the cPanel, Scroll down to the&nbsp;<strong>Software</strong>&nbsp;section.</li>



<li>Click&nbsp;<strong>Setup Node.js App</strong>.</li>



<li>Click + <strong>Create Application</strong>.</li>



<li>Node.js version selection: It&#8217;s critical to select the Node.js version that matches the one you used for local development. This ensures compatibility and avoids potential runtime errors.</li>



<li>Application mode: Select <strong>Production.</strong></li>



<li>Application root: Type <strong>app </strong>or your chosen directory</li>



<li>Application URL: Choose your domain name.</li>



<li>Application startup file: <code>dist/your-app-name/server/server.mjs</code></li>
</ul>



<p class="wp-block-paragraph"><em>If you have any environment variables, you can add them from your <code>.env or .env.local file.</code></em></p>



<figure class="wp-block-image size-large"><img decoding="async" src="https://blog.aveshost.com/wp-content/uploads/2025/02/Deploy-Angular-app-on-cPanel-ng-new-SSR-nodejs-setup-1024x609.png" alt="Deploy Angular app on cPanel - ng new SSR nodejs setup.png" class="wp-image-3139"/></figure>



<ul class="wp-block-list">
<li>Click on <strong>CREATE</strong> to create the Node.js application.</li>



<li>Stop the app. Then, go to &#8216;Detected Configuration Files&#8217;. If <code>package.json</code> doesn&#8217;t appear, refresh the page.</li>



<li>Click “<strong>Run NPM Install</strong>” to install the dependencies specified in your&nbsp;<code>package.json</code>&nbsp;file.</li>
</ul>



<p class="wp-block-paragraph"><strong>Note:</strong> You can also use the Terminal to install dependencies. Simply return to your cPanel dashboard or search for &#8220;Terminal&#8221; in the top search bar.</p>



<p class="wp-block-paragraph"><em>Activate the Node.js environment. Click to copy the provided command at the top and execute it in the terminal.&nbsp;</em></p>



<pre class="wp-block-code"><code>source /home/username/nodevenv/app/20/bin/activate &amp;&amp; cd /home/username/app
Example: source /home/username/nodevenv/app/20/bin/activate &amp;&amp; cd /home/username/app</code></pre>



<p class="wp-block-paragraph"><em>(Replace&nbsp;<code>20</code>&nbsp;with your selected Node.js version.)</em></p>



<p class="wp-block-paragraph">Once the Node.js environment is activated, run the <code>npm install</code> command. </p>



<p class="wp-block-paragraph"><strong>Note:</strong> You don’t need to run the <code>npm install</code> command again in the Terminal if <strong>&#8220;Run NPM Install&#8221;</strong> was successfully executed earlier.</p>



<ul class="wp-block-list">
<li>Restart the application by clicking the &#8216;<strong>START APP</strong>&#8216; button.</li>
</ul>



<p class="wp-block-paragraph">Open a new browser tab and navigate to your website&#8217;s URL. You should now see your New  Angular SSR application successfully running.</p>



<p class="wp-block-paragraph">Congratulations! You&#8217;ve successfully deployed your Angular SSR application on cPanel.</p>



<h2 class="wp-block-heading" id="troubleshooting-tips">Troubleshooting Tips</h2>



<h3 class="wp-block-heading" id="1-blank-screen-after-deployment">1. Blank Screen After Deployment?</h3>



<ul class="wp-block-list">
<li>Check the browser console for errors.</li>



<li>Verify that <code>base-href</code> is correctly set in <code>index.html</code>.</li>



<li>Ensure <code>.htaccess</code> is configured correctly.</li>
</ul>



<h3 class="wp-block-heading" id="2-angular-ssr-not-rendering-on-c-panel">2. Angular SSR Not Rendering on cPanel?</h3>



<ul class="wp-block-list">
<li>Make sure Node.js is running.</li>



<li>Verify that your Node.js version is compatible with your Angular application.</li>
</ul>



<h3 class="wp-block-heading" id="3-500-internal-server-error">3. 500 Internal Server Error?</h3>



<ul class="wp-block-list">
<li>Check <code>stderr.log</code> or <code>error_log</code> in <strong>your app folder or your chosen directory</strong>.</li>



<li>Ensure correct permissions (use <code>755</code> for directories and <code>644</code> for files).</li>
</ul>



<h2 class="wp-block-heading" id="conclusion">Conclusion</h2>



<p class="wp-block-paragraph">Deploying an Angular app on cPanel may seem tricky, but following these steps makes it simple. Whether you’re hosting a client-side or server-side app, cPanel can handle it with the right configurations.</p>



<p class="wp-block-paragraph">Have any questions? Drop them in the comments below! <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f680.png" alt="🚀" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>



<p class="wp-block-paragraph"><strong>Suggested Reading:</strong></p>



<ul class="wp-block-list">
<li><a href="https://blog.aveshost.com/how-to-deploy-a-node-js-app-on-cpanel/">How To Deploy a Node.js App on cPanel (The Ultimate Guide)</a></li>



<li><a href="https://blog.aveshost.com/how-to-deploy-laravel-project-on-cpanel/">How to Deploy Laravel Project on cPanel</a></li>



<li><a href="https://blog.aveshost.com/how-to-buy-cpanel-hosting/">How to Buy cPanel Hosting for Your Website: Beginner’s Guide</a></li>



<li><a href="https://blog.aveshost.com/how-to-set-up-mysql-database-in-cpanel/">How to Set Up a MySQL Database &amp; User in cPanel (2 Easy Methods)</a></li>



<li><a href="https://blog.aveshost.com/git-commands-with-downloadable-cheat-sheet/">50+ Essential Git Commands (With Downloadable Cheat Sheet)</a></li>



<li><a href="https://blog.aveshost.com/essential-linux-commands/">Top 90+ Essential Linux Commands Plus Cheat Sheet</a></li>
</ul>



<h2 class="wp-block-heading" id="frequently-asked-questions-fa-qs">Frequently Asked Questions (FAQs)</h2>


<div id="rank-math-faq" class="rank-math-block">
<div class="rank-math-list ">
<div id="rm-faq-f33f9ae7a6a6ff92bd24282185a66236" class="rank-math-list-item">
<h3 class="rank-math-question ">What are the prerequisites for deploying an Angular app on cPanel?</h3>
<div class="rank-math-answer ">

<p>You need a cPanel hosting account, a domain or subdomain set up, Angular installed locally, FTP or cPanel File Manager access, and basic knowledge of Angular CLI and hosting environments.</p>

</div>
</div>
<div id="rm-faq-e726ea151f84b02938edf91888b27744" class="rank-math-list-item">
<h3 class="rank-math-question ">Why is Node.js version synchronization important before deploying an Angular app on cPanel?</h3>
<div class="rank-math-answer ">

<p>Matching the Node.js version on your local machine with the one on cPanel prevents deployment errors and ensures compatibility, as discrepancies can cause hard-to-debug issues.</p>

</div>
</div>
<div id="rm-faq-47263270d79e3c4debaa75097baa480e" class="rank-math-list-item">
<h3 class="rank-math-question ">How do you deploy a client-side rendered (CSR) Angular app on cPanel?</h3>
<div class="rank-math-answer ">

<p>Build the Angular app using &#8216;ng build&#8217;, upload the contents of the &#8216;browser&#8217; folder from the &#8216;dist&#8217; directory to cPanel via File Manager or FTP, and configure a .htaccess file for Angular routing.</p>

</div>
</div>
<div id="rm-faq-3c0af1f48f660d21b4e14170fede87f2" class="rank-math-list-item">
<h3 class="rank-math-question ">What is the difference between client-side rendering (CSR) and server-side rendering (SSR) in Angular?</h3>
<div class="rank-math-answer ">

<p>CSR renders the app in the browser using JavaScript, while SSR pre-renders the app on the server, sending fully rendered HTML to improve initial load times and SEO.</p>

</div>
</div>
<div id="rm-faq-f2a1733c949dfe6f2e28b0de6f9a8546" class="rank-math-list-item">
<h3 class="rank-math-question ">How do you check the Node.js version on cPanel?</h3>
<div class="rank-math-answer ">

<p>Navigate to &#8216;Setup Node.js App&#8217; in cPanel, click &#8216;+CREATE APPLICATION&#8217;, and check the &#8216;Node.js version&#8217; dropdown to see the version used in your cPanel environment.</p>

</div>
</div>
<div id="rm-faq-d564d54efdf95a0e4df751720bce9a0a" class="rank-math-list-item">
<h3 class="rank-math-question ">What should you do if your local Node.js version doesn&#8217;t match cPanel&#8217;s version?</h3>
<div class="rank-math-answer ">

<p>Use Node Version Manager (nvm) to install and switch to the matching Node.js version locally, then verify with &#8216;node -v&#8217; and test your Angular app before building for deployment.</p>

</div>
</div>
</div>
</div>]]></content:encoded>
					
					<wfw:commentRss>https://blog.aveshost.com/how-to-deploy-angular-app-on-cpanel/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How To Deploy a Node.js App on cPanel (The Ultimate Guide)</title>
		<link>https://blog.aveshost.com/how-to-deploy-a-node-js-app-on-cpanel/</link>
					<comments>https://blog.aveshost.com/how-to-deploy-a-node-js-app-on-cpanel/#respond</comments>
		
		<dc:creator><![CDATA[James Wilson]]></dc:creator>
		<pubDate>Sat, 22 Feb 2025 03:00:00 +0000</pubDate>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[#CloudLinux]]></category>
		<category><![CDATA[#cPanelHosting]]></category>
		<category><![CDATA[#DeployNodeJS]]></category>
		<category><![CDATA[#HostingGuide]]></category>
		<category><![CDATA[#NodeJS]]></category>
		<category><![CDATA[#SharedHosting]]></category>
		<guid isPermaLink="false">https://blog.aveshost.com/?p=3058</guid>

					<description><![CDATA[How to Host a Node.JS Application With cPanel To deploy a Node.js application on cPanel might seem a bit tricky at first, especially if you&#8217;re more accustomed to traditional PHP deployments. But don’t worry! By the end of this guide, you’ll be confident enough to get your Node.js app up and running on cPanel smoothly. [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading" id="how-to-host-a-node-js-application-with-c-panel">How to Host a Node.JS Application With cPanel</h2>



<p class="wp-block-paragraph">To deploy a Node.js application on cPanel might seem a bit tricky at first, especially if you&#8217;re more accustomed to traditional PHP deployments. But don’t worry! By the end of this guide, you’ll be confident enough to get your Node.js app up and running on cPanel smoothly. </p>



<div class="wp-block-rank-math-toc-block" id="rank-math-toc"><h2>Table of Contents</h2><nav><div><div><a href="#how-to-host-a-node-js-application-with-c-panel">How to Host a Node.JS Application With cPanel</a></div><div><a href="#why-deploy-node-js-on-c-panel">Why Deploy Node.js on cPanel?</a></div><div><a href="#before-we-begin-prerequisites">Before We Begin: Prerequisites</a></div><div><a href="#step-1-accessing-c-panel">Step 1: Accessing cPanel</a></div><div><a href="#step-2-create-a-new-node-js-application">Step 2: Create a New Node.js Application</a></div><div><a href="#step-3-upload-your-application-files">Step 3: Upload Your Application Files</a></div><div><a href="#step-4-install-dependencies">Step 4: Install Dependencies</a></div><div><a href="#step-5-connecting-to-your-database-optional">Step 5: Connecting to Your Database (Optional)</a></div><div><a href="#step-6-restart-your-application">Step 6: Restart Your Application</a></div><div><a href="#step-7-setting-environment-variables-optional">Step 7: Setting Environment Variables (Optional)</a></div><div><a href="#video-tutorials">Video Tutorials</a></div><div><a href="#troubleshooting-common-issues">Troubleshooting Common Issues</a></div><div><a href="#securing-your-node-js-application">Securing Your Node.js Application</a></div><div><a href="#final-thoughts">Final Thoughts</a></div><div><a href="#frequently-asked-questions-fa-qs">Frequently Asked Questions (FAQs)</a></div></div></nav></div>



<p class="wp-block-paragraph">Let’s dive into every detail, from setting up your environment to troubleshooting common issues.</p>



<h2 class="wp-block-heading" id="why-deploy-node-js-on-c-panel">Why Deploy Node.js on cPanel?</h2>



<p class="wp-block-paragraph">cPanel is one of the most popular <a href="https://www.aveshost.com/web-hosting" rel="noopener">web hosting</a> control panels. It&#8217;s user-friendly, robust, and widely supported by hosting providers. If you&#8217;re developing with Node.js, deploying on cPanel allows you to take advantage of its powerful management tools while enjoying the speed and flexibility of Node.js.</p>



<h2 class="wp-block-heading" id="before-we-begin-prerequisites">Before We Begin: Prerequisites</h2>



<p class="wp-block-paragraph">Before diving into the deployment process, make sure you have the following ready:</p>



<ul class="wp-block-list">
<li><strong>A Node.js Application:</strong> You should have a working Node.js application ready for deployment.</li>



<li><strong>cPanel Access:</strong> You&#8217;ll need access to your cPanel account, including your username and password. If you don&#8217;t have cPanel hosting, follow this guide to acquire it: &#8220;<a href="https://blog.aveshost.com/how-to-buy-cpanel-hosting/">How to Buy cPanel Hosting</a>&#8221;                                                                                                                                                                                                                                                          </li>



<li><strong>SSH Access (Optional):</strong> While some methods don&#8217;t require SSH, it&#8217;s highly recommended for easier management and deployment. Contact your <a href="https://www.aveshost.com/" rel="noopener">hosting provider</a> if you&#8217;re unsure how to enable SSH.</li>



<li><strong>Basic Understanding of Node.js and npm:</strong> Familiarity with Node.js and <a href="https://www.npmjs.com/" rel="noopener">npm </a>(Node Package Manager) will be beneficial.</li>
</ul>



<h2 class="wp-block-heading" id="step-1-accessing-c-panel">Step 1: Accessing cPanel</h2>



<p class="wp-block-paragraph">Log into your cPanel dashboard. This is usually accessible at <code>https://yourdomainname.com/cpanel</code> or by visiting the <a href="https://my.aveshost.com/clientarea.php?action=services" rel="noopener">hosting services</a> page of your account dashboard. </p>



<p class="wp-block-paragraph">Once inside the cPanel, locate the <strong>&#8220;Setup Node.js App&#8221;</strong> feature.</p>



<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" width="910" height="876" src="https://blog.aveshost.com/wp-content/uploads/2025/02/locate-and-deploy-a-node.js-app.png" alt="Locate and deploy a node.js app" class="wp-image-3060" style="width:673px;height:auto" srcset="https://blog.aveshost.com/wp-content/uploads/2025/02/locate-and-deploy-a-node.js-app.png 910w, https://blog.aveshost.com/wp-content/uploads/2025/02/locate-and-deploy-a-node.js-app-300x289.png 300w, https://blog.aveshost.com/wp-content/uploads/2025/02/locate-and-deploy-a-node.js-app-768x739.png 768w" sizes="(max-width: 910px) 100vw, 910px" /></figure>



<h2 class="wp-block-heading" id="step-2-create-a-new-node-js-application">Step 2: Create a New Node.js Application</h2>



<ol class="wp-block-list">
<li>Scroll down to the <strong>Software</strong> section.</li>



<li>Click <strong>Setup Node.js App</strong>.</li>



<li>Click <strong>Create Application</strong> and configure the following:
<ul class="wp-block-list">
<li><strong>Node.js Version</strong>: Select the required version.</li>



<li><strong>Application Mode</strong>: Choose <strong>Production</strong>.</li>



<li><strong>Application Root</strong>: Enter the directory where you will upload your app (e.g., <code>/home/username/app</code>).</li>



<li><strong>Application URL</strong>: Choose the domain or subdomain.</li>



<li><strong>Application Startup File</strong>: Enter <code>server.js</code> (or your app’s main file).</li>
</ul>
</li>
</ol>



<figure class="wp-block-image size-large"><img decoding="async" src="https://blog.aveshost.com/wp-content/uploads/2025/02/Create-a-New-Node.js-Application-1024x604.png" alt="Create a New Node.js Application" class="wp-image-3062"/></figure>



<ol start="4" class="wp-block-list">
<li>Click <strong>Create</strong>.</li>
</ol>



<figure class="wp-block-image size-large"><img decoding="async" src="https://blog.aveshost.com/wp-content/uploads/2025/02/Node.js-app-created-1024x588.png" alt="Node.js app created" class="wp-image-3064"/></figure>



<p class="wp-block-paragraph">Congratulations! Your Node.js application has been successfully created. You can now visit your domain, where you should see a confirmation message similar to &#8220;<strong>It works! NodeJS 16.20.2</strong>&#8220;.</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://blog.aveshost.com/wp-content/uploads/2025/02/Node.js-app-working-1-1.png" alt="Node.js app working" class="wp-image-3068" style="width:519px;height:auto"/></figure>



<h2 class="wp-block-heading" id="step-3-upload-your-application-files">Step 3: Upload Your Application Files</h2>



<ol class="wp-block-list">
<li>Open <strong>File Manager</strong> in cPanel.</li>



<li>Navigate to the application root directory (e.g., <code>/home/username/app</code>).</li>
</ol>



<figure class="wp-block-image size-large"><img decoding="async" src="https://blog.aveshost.com/wp-content/uploads/2025/02/Node.js-Application-root-directory-1024x270.png" alt="Node.js Application root directory" class="wp-image-3070"/></figure>



<ol start="3" class="wp-block-list">
<li>Upload your project files, including <code>package.json</code> and <code>server.js</code>. On your local machine, navigate to your Node.js project folder and create a zip archive of your project files. While generally not recommended due to its size, including the <code>node_modules</code> folder in the zip archive is advisable if your cPanel hosting does not support terminal access or if the <code>npm install</code> command fails when executed via the terminal.</li>
</ol>



<figure class="wp-block-image size-large"><img decoding="async" src="https://blog.aveshost.com/wp-content/uploads/2025/02/Node.js-project-files-1024x348.png" alt="Node.js project files" class="wp-image-3072"/></figure>



<ol start="4" class="wp-block-list">
<li>Extract the uploaded archive. Once extracted, navigate into the resulting folder, select all the files and folders within, and move them to your application directory (e.g., <code>/app</code>).</li>
</ol>



<figure class="wp-block-image size-large"><img decoding="async" src="https://blog.aveshost.com/wp-content/uploads/2025/02/Moving-the-Node.js-files-1024x527.png" alt="Moving the Node.js files" class="wp-image-3074"/></figure>



<p class="wp-block-paragraph"><strong>Suggested Reading:</strong> <a href="https://blog.aveshost.com/how-to-upload-your-website/">How to Upload Your Website (in 3 Simple Steps)</a></p>



<h2 class="wp-block-heading" id="step-4-install-dependencies">Step 4: Install Dependencies</h2>



<p class="wp-block-paragraph">If you have already uploaded your <code>node_modules</code> folder, skip this step and proceed to <strong>Step 5</strong> or <strong>Step 6</strong>.</p>



<ol class="wp-block-list">
<li>Return to <strong>Setup Node.js App</strong>.</li>



<li>Click the pencil icon &#8220;<strong>Edit the Application</strong>&#8221; under the <strong>Actions </strong>column to make changes.</li>



<li>Activate the Node.js environment. Click to copy the provided command and execute it in the terminal. Alternatively, you can click &#8220;<strong>Run NPM Install</strong>&#8221; to install the dependencies specified in your <code>package.json</code> file. While the &#8220;<strong>Run NPM Install</strong>&#8221; option is convenient, using the terminal is generally preferred, unless terminal access is unavailable on your hosting account.</li>
</ol>



<figure class="wp-block-image size-large"><img decoding="async" src="https://blog.aveshost.com/wp-content/uploads/2025/02/node.js-environment-activation-command-1024x685.png" alt="node.js environment activation command" class="wp-image-3076"/></figure>



<pre class="wp-block-code"><code><em>source /home/username/nodevenv/app/16/bin/activate &amp;&amp; cd /home/username/app</em>
<em>Example: source /home/cpusrplus/nodevenv/app/16/bin/activate &amp;&amp; cd /home/cpusrplus/app</em></code></pre>



<p class="wp-block-paragraph">(Replace <code>16</code> with your selected Node.js version.)</p>



<h3 class="wp-block-heading" id="access-the-terminal">Access The Terminal</h3>



<ol class="wp-block-list">
<li>Return to the cPanel dashboard</li>



<li>Scroll down to the <strong>Advanced</strong> section.</li>



<li>Click <strong>Terminal </strong></li>



<li>Alternatively, use the cPanel search bar at the top of the interface to locate the terminal.</li>
</ol>



<figure class="wp-block-image size-large"><img decoding="async" src="https://blog.aveshost.com/wp-content/uploads/2025/02/cPanel-terminal-access-1024x439.png" alt="cPanel terminal access" class="wp-image-3078"/></figure>



<ol start="5" class="wp-block-list">
<li>Paste the command copied from Step 4 into the terminal to activate the Node.js environment. Then, execute <code>npm install</code> to install the project dependencies.</li>
</ol>



<figure class="wp-block-image size-large"><img decoding="async" src="https://blog.aveshost.com/wp-content/uploads/2025/02/Node.js-environment-1024x328.png" alt="Node.js environment" class="wp-image-3080"/></figure>



<p class="wp-block-paragraph">If you encounter issues installing dependencies or if package installation is unsuccessful, there could be an issue with the installed Node.js version. Delete your current Node.js application setup and install a lower version, such as Node.js 16 or below.</p>



<h2 class="wp-block-heading" id="step-5-connecting-to-your-database-optional">Step 5: Connecting to Your Database (Optional)</h2>



<p class="wp-block-paragraph">If your Node.js app requires a database, follow one of the two guides below to create and configure the database within your application.</p>



<ul class="wp-block-list">
<li><a href="https://blog.aveshost.com/how-to-set-up-mysql-database-in-cpanel/">How to Set Up a MySQL Database &amp; User in cPanel (2 Easy Methods)</a></li>



<li><a href="https://blog.aveshost.com/how-to-set-up-postgresql-database-in-cpanel/">How to Set Up a PostgreSQL Database and User in cPanel</a></li>
</ul>



<ol class="wp-block-list">
<li><strong>Locate the&nbsp;<code>.env</code>&nbsp;File</strong>
<ul class="wp-block-list">
<li>Navigate to your Node.js project directory.</li>



<li>If the&nbsp;<code>.env</code>&nbsp;file is not visible, click on&nbsp;<strong>Settings</strong>&nbsp;in the top-right corner and enable&nbsp;<strong>Show Hidden Files (dotfiles)</strong>.</li>



<li>If the&nbsp;<code>.env</code>&nbsp;file is still missing, re-upload it from your local machine.</li>
</ul>
</li>



<li><strong>Edit the&nbsp;<code>.env</code>&nbsp;File</strong>
<ul class="wp-block-list">
<li>Open the&nbsp;<code>.env</code>&nbsp;file in a text editor.</li>



<li>Update the necessary database configurations as required.</li>
</ul>
</li>
</ol>



<pre class="wp-block-code"><code>DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=yourCpanelUsername_yourDbName
DB_USERNAME=yourCpanelUsername_yourDbUsername
DB_PASSWORD=yourDatabasePassword</code></pre>



<ol start="3" class="wp-block-list">
<li>Import your database file from your local machine
<ul class="wp-block-list">
<li>Export your database from your local development environment (e.g., XAMPP, WAMP).</li>



<li>In your cPanel, scroll down to the <strong>Databases</strong> section</li>



<li>Click <strong>phpMyAdmin</strong></li>



<li>The database you created should appear in the left-hand panel. Click to select it.</li>



<li>Click <strong>Import</strong> at the top to upload your database from your local machine.</li>
</ul>
</li>
</ol>



<p class="wp-block-paragraph"><strong>Suggested Reading:</strong> <a href="https://my.aveshost.com/knowledgebase/26/How-to-Import-a-Database-in-cPanel-Using-phpMyAdmin.html" target="_blank" rel="noreferrer noopener">How to Import a Database in phpMyAdmin</a></p>



<h2 class="wp-block-heading" id="step-6-restart-your-application">Step 6: Restart Your Application</h2>



<ol class="wp-block-list">
<li>Return to <strong>Setup Node.js App</strong>.</li>



<li>Click <strong>Restart</strong> to apply the changes</li>
</ol>



<p class="wp-block-paragraph">Your Node.js app is now live! <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f389.png" alt="🎉" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>



<figure class="wp-block-image size-large is-resized"><img decoding="async" src="https://blog.aveshost.com/wp-content/uploads/2025/02/node.js-app-is-live-1024x483.png" alt="Node.js App is live" class="wp-image-3083" style="width:748px;height:auto"/></figure>



<h2 class="wp-block-heading" id="step-7-setting-environment-variables-optional">Step 7: Setting Environment Variables (Optional)</h2>



<p class="wp-block-paragraph">To manage sensitive data like API keys, you’ll need to set environment variables.</p>



<ul class="wp-block-list">
<li>In <strong>Setup Node.js App</strong>, scroll down to <strong>Environment Variables</strong>.</li>



<li>Click <strong>Add Variable</strong> and enter the <strong>Name</strong> and <strong>Value</strong>. For example:
<ul class="wp-block-list">
<li><strong>Name</strong>: <code>PORT</code></li>



<li><strong>Value</strong>: <code>7000</code></li>
</ul>
</li>



<li>Save changes and restart the app.</li>
</ul>



<p class="wp-block-paragraph">You can then access these variables in your code using <code>process.env.VARIABLE_NAME</code>.</p>



<h2 class="wp-block-heading" id="video-tutorials">Video Tutorials</h2>



<p class="wp-block-paragraph">These video tutorials provide visual guidance, making it even easier to deploy your Node.js app on cPanel. Learn how to deploy to your main domain or a subdomain, following along with clear, concise demonstrations.</p>



<h3 class="wp-block-heading" id="how-to-deploy-a-node-js-app-on-c-panel-using-the-main-domain-or-root-domain">How To Deploy a Node.js App on cPanel Using the Main Domain (or Root Domain)</h3>



<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe title="How to Deploy a Node.js App on cPanel (The Ultimate Guide)" width="500" height="281" src="https://www.youtube.com/embed/XYSg5LMZka8?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>



<p class="wp-block-paragraph">This video walks you through the process of deploying your Node.js application to your cPanel hosting account using your main domain name (e.g., <code>domain.com</code>). It covers setting up the necessary files, configuring your cPanel environment, and getting your app live on your primary domain. Perfect for beginners!</p>



<h3 class="wp-block-heading" id="how-to-deploy-a-node-js-app-on-c-panel-using-a-subdomain">How To Deploy a Node.js App on cPanel Using a Subdomain</h3>



<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe title="How To Deploy Node.js Application on cPanel Using Subdomain" width="500" height="281" src="https://www.youtube.com/embed/2JSkn-Rz66s?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>



<p class="wp-block-paragraph">This video demonstrates how to deploy your Node.js application to a subdomain (e.g., <code>app.domain.com</code>) on your cPanel server. It covers the specific steps required for subdomain deployment, including setting up the subdomain in cPanel and configuring your application to run under the subdomain. Great if you want to host multiple applications on the same cPanel account!</p>



<h2 class="wp-block-heading" id="troubleshooting-common-issues">Troubleshooting Common Issues</h2>



<h3 class="wp-block-heading" id="1-website-showing-503-error">1. Website Showing 503 Error</h3>



<p class="wp-block-paragraph">If you&#8217;re unlucky, you may encounter the following error when trying to access your deployed Node.js website, as shown in the screenshot below.</p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://blog.aveshost.com/wp-content/uploads/2025/02/common-errors-with-nodejs.png" alt="Common Issues with Node.js" class="wp-image-3082" style="width:475px;height:auto"/></figure>



<p class="wp-block-paragraph">To view the error logs, navigate to your Node.js application&#8217;s root directory (e.g., <code>/app</code>) within the File Manager.</p>



<p class="wp-block-paragraph">Right-click the <code>stderr.log</code> file and select &#8220;View&#8221; (or the equivalent option in your file manager) to examine its contents.</p>



<pre class="wp-block-code"><code>server.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.
Instead rename server.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /home/cpusrplus/app/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead)

  code: 'ERR_REQUIRE_ESM'
}</code></pre>



<p class="wp-block-paragraph">If you encounter any of the errors displayed above, follow the corresponding steps to resolve them.</p>



<ol class="wp-block-list">
<li>Edit the <code>package.json</code> file and change <code>"type": "module"</code> to <code>"type": "commonjs"</code>.  </li>



<li>Save the <code>package.json</code> file.</li>



<li>Return to <strong>Setup Node.js App</strong>.</li>



<li>Click <strong>Restart</strong> to apply the changes</li>



<li>Access your site; the error should be resolved.</li>
</ol>



<h3 class="wp-block-heading" id="2-application-not-starting">2. Application Not Starting</h3>



<ul class="wp-block-list">
<li>Check the startup file path and ensure it&#8217;s correctly set.</li>



<li>Check the <code>stderr.log </code>in your Application Directory</li>



<li>Look at the logs in <strong>File Manager</strong> → <code>logs</code> directory.</li>
</ul>



<h3 class="wp-block-heading" id="3-dependencies-not-installing">3. Dependencies Not Installing</h3>



<ul class="wp-block-list">
<li>Make sure your <code>package.json</code> is present in the root directory.</li>



<li>Make sure virtual environment for Node.js applications is activated.</li>
</ul>



<pre class="wp-block-code"><code>source /home/username/nodevenv/app/16/bin/activate   <em>#replace 16 with your Node.js v</em>ersion <em>&amp; app with your node.js application directory.</em></code></pre>



<ul class="wp-block-list">
<li>Clear cache and reinstall dependencies</li>
</ul>



<pre class="wp-block-code"><code>npm cache clean --force
npm install</code></pre>



<h2 class="wp-block-heading" id="securing-your-node-js-application"> Securing Your Node.js Application</h2>



<ol class="wp-block-list">
<li><strong><a href="https://blog.aveshost.com/redirect-http-to-https/">Enable HTTPS</a></strong>: Use <strong>Let&#8217;s Encrypt SSL</strong> in cPanel to secure your application with HTTPS.</li>



<li><strong>Firewall Configuration</strong>: Make sure the port used by your app is open.</li>



<li><strong>Environment Variables</strong>: Never hardcode sensitive information. Always use environment variables.</li>
</ol>



<h2 class="wp-block-heading" id="final-thoughts">Final Thoughts</h2>



<p class="wp-block-paragraph">Deploying a Node.js application on cPanel can be straightforward if you follow the right steps. This guide covered everything you need to get your Node.js app live on cPanel.</p>



<p class="wp-block-paragraph">By leveraging cPanel&#8217;s powerful features and Node.js&#8217;s performance, you can build and deploy robust web applications effortlessly.</p>



<p class="wp-block-paragraph">Happy coding! <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f680.png" alt="🚀" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>



<div style="height:28px" aria-hidden="true" class="wp-block-spacer"></div>



<div style="height:26px" aria-hidden="true" class="wp-block-spacer"></div>



<p class="wp-block-paragraph"><strong>Suggested Reading:</strong></p>



<ul class="wp-block-list">
<li><a href="https://blog.aveshost.com/how-to-deploy-laravel-project-on-cpanel/">How to Deploy Laravel Project on cPanel</a></li>



<li><a href="https://blog.aveshost.com/how-to-remove-html-php-from-urls/">How to Remove .html, .php, or Both from URLs</a></li>



<li><a href="https://blog.aveshost.com/how-to-buy-cpanel-hosting/">How to Buy cPanel Hosting for Your Website: Beginner’s Guide</a></li>



<li><a href="https://blog.aveshost.com/essential-linux-commands/">Top 90+ Essential Linux Commands Plus Cheat Sheet</a></li>



<li><a href="https://blog.aveshost.com/git-commands-with-downloadable-cheat-sheet/">50+ Essential Git Commands (With Downloadable Cheat Sheet)</a></li>



<li><a href="https://blog.aveshost.com/how-to-flush-dns/">How to Flush DNS Cache on Windows, Mac, Linux &amp; Browsers</a></li>



<li><a href="https://blog.aveshost.com/redirect-http-to-https/">How to Redirect HTTP to HTTPS: Ultimate Guide to Secure Site</a></li>



<li><a href="https://blog.aveshost.com/how-to-transfer-your-domain/">How To Transfer Your Domain: A Step-by-Step Guide</a></li>
</ul>



<h2 class="wp-block-heading" id="frequently-asked-questions-fa-qs">Frequently Asked Questions (FAQs)</h2>


<div id="rank-math-faq" class="rank-math-block">
<div class="rank-math-list ">
<div id="rm-faq-fd98d714658a4963c4c556bc2baa53c2" class="rank-math-list-item">
<h3 class="rank-math-question ">What are the prerequisites for deploying a Node.js app on cPanel?</h3>
<div class="rank-math-answer ">

<p>You need a working Node.js application, cPanel access with username/password, optional SSH access (recommended), and basic understanding of Node.js and npm.</p>

</div>
</div>
<div id="rm-faq-54c8cece60af2923cb141735f61ae51a" class="rank-math-list-item">
<h3 class="rank-math-question ">How do I create a Node.js application in cPanel?</h3>
<div class="rank-math-answer ">

<p>In cPanel, go to &#8216;Setup Node.js App&#8217; under Software section, click &#8216;Create Application&#8217;, configure Node.js version, application mode, root directory, URL, and startup file, then click &#8216;Create&#8217;.</p>

</div>
</div>
<div id="rm-faq-872f6e5b34ed077dca8930adfda07c23" class="rank-math-list-item">
<h3 class="rank-math-question ">How do I upload my Node.js application files to cPanel?</h3>
<div class="rank-math-answer ">

<p>Use File Manager to navigate to your application root directory, upload a zip archive of your project files (including package.json and server.js), extract it, and move all files to your app directory.</p>

</div>
</div>
<div id="rm-faq-8e63e211a33e6a48974b0a66fb6c6a8a" class="rank-math-list-item">
<h3 class="rank-math-question ">How do I install dependencies for my Node.js app on cPanel?</h3>
<div class="rank-math-answer ">

<p>In &#8216;Setup Node.js App&#8217;, click the pencil icon to edit your application, activate the Node.js environment, then either use &#8216;Run NPM Install&#8217; or execute &#8216;npm install&#8217; in the terminal with the provided activation command.</p>

</div>
</div>
<div id="rm-faq-34e1940bf6d8087b6891af4834cd13b6" class="rank-math-list-item">
<h3 class="rank-math-question ">How do I configure database connections for my Node.js app on cPanel?</h3>
<div class="rank-math-answer ">

<p>Create a database in cPanel, locate or upload your .env file in the project directory, update database configuration variables (DB_HOST, DB_PORT, etc.), and import your database file via phpMyAdmin if needed.</p>

</div>
</div>
<div id="rm-faq-33fcf82551fa5ec047a5399809c082db" class="rank-math-list-item">
<h3 class="rank-math-question ">What should I do if I encounter issues installing dependencies?</h3>
<div class="rank-math-answer ">

<p>If npm install fails, there might be a Node.js version compatibility issue. Delete your current Node.js application setup and recreate it with a lower version such as Node.js 16 or below.</p>

</div>
</div>
</div>
</div>]]></content:encoded>
					
					<wfw:commentRss>https://blog.aveshost.com/how-to-deploy-a-node-js-app-on-cpanel/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
