<?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>#DeployAngular &#8211; Aveshost Blog</title>
	<atom:link href="https://blog.aveshost.com/tag/deployangular/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:40:22 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0</generator>

<image>
	<url>https://blog.aveshost.com/wp-content/uploads/2026/01/logo-150x150.png</url>
	<title>#DeployAngular &#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>
	</channel>
</rss>
