You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在GoDaddy的cPanel/Plesk Odin共享主机部署Angular与Node.js项目

Hey there! Let's break down how to deploy your Angular and Node.js projects on both cPanel and Plesk Odin shared hosting from GoDaddy. I’ve walked through these steps a bunch of times, so I’ll keep it straightforward and tailored to shared hosting constraints.

Deploying Angular & Node.js on GoDaddy Shared Hosting (cPanel + Plesk Odin)

For cPanel Hosting

Deploying Angular Projects

Angular apps need to be built for production first, then uploaded to your hosting root:

  • Local Build: Run ng build --prod in your Angular project folder. This generates a dist directory with optimized, production-ready files.
  • Upload & Extract: Compress the dist folder into a ZIP file. Log into cPanel, open File Manager, navigate to your domain’s root directory (usually public_html), upload the ZIP, then right-click and extract its contents directly into the root.
  • Fix Routing: If your Angular app uses client-side routing, create a .htaccess file in public_html with this code to ensure all routes redirect to index.html:
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  RewriteRule ^index\.html$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.html [L]
</IfModule>
  • Test: Visit your domain in a browser—your Angular app should load, and all routes should work as expected.

Deploying Node.js Projects

cPanel has a built-in Node.js manager to simplify deployment:

  • Create Node App: Log into cPanel, find Node.js Selector (sometimes labeled "Setup Node.js App"). Click Create Application, then fill in:
    • Application root: A folder name (e.g., my-node-app—this lives outside public_html for security)
    • Application URL: Select your domain/subdomain
    • Application startup file: Your entry point (e.g., server.js)
    • Node.js version: Match the version you used for local development
  • Upload Project: Use FTP or cPanel’s File Manager to upload your Node project files (including package.json) to the application root folder you just created.
  • Install Dependencies: Back in the Node.js Selector, find your app and click Run NPM Install to install all required packages.
  • Start the App: Click Start Application, then visit your configured URL to test the app.
  • Extra: Add environment variables via the Environment Variables tab in the Node.js Selector, and double-check your database connection string (GoDaddy databases use localhost and prefixed usernames).

For Plesk Odin Hosting

Deploying Angular Projects

Plesk uses httpdocs as the default root directory—here’s how to get your Angular app up:

  • Local Build: Same as cPanel: run ng build --prod to generate the dist folder, then compress it to ZIP.
  • Upload & Extract: Log into Plesk Odin, go to your domain’s Files section, navigate to httpdocs, upload the ZIP, and extract its contents.
  • Fix Routing: Either create a .htaccess file with the same rewrite rules as cPanel, or go to Apache & Nginx Settings and add this Nginx rule:
if (!-e $request_filename){
    rewrite ^(.*)$ /index.html break;
}
  • Test: Visit your domain to confirm the Angular app loads and routes work.

Deploying Node.js Projects

Plesk’s Node.js tooling is similar to cPanel but with a slightly different workflow:

  • Add Node App: In your domain’s Plesk panel, find Node.js (under Applications or Web Apps). Click Add Node.js App, then configure:
    • Document root: Choose a folder (e.g., node-app—best to keep this outside httpdocs or use a subdomain)
    • Application mode: Select Production
    • Application root: The folder where you’ll upload your project files
    • Startup file: Your entry point (e.g., server.js)
    • Node.js version: Match your local development version
  • Upload Files: Use FTP or Plesk’s File Manager to upload your Node project to the application root folder.
  • Install Dependencies: In the Node.js app panel, click Install Dependencies to run npm install.
  • Start the App: Click Start App, then test the app via its configured URL.
  • Extra: Add environment variables in the Environment tab of the Node.js panel, and verify your database connection details (Plesk databases also use localhost and prefixed usernames).

General Tips for GoDaddy Shared Hosting

  • Resource Limits: Shared hosting has strict memory/CPU limits—keep your Node.js app lightweight to avoid being auto-paused.
  • Version Matching: Always use the same Node.js version locally and on the host to avoid dependency compatibility issues.
  • Permissions: Set folder permissions to 755 and file permissions to 644 (avoid 777—it’s a major security risk).
  • Angular Optimization: Never skip the --prod flag when building—this reduces file size drastically and improves load times.

内容的提问来源于stack exchange,提问作者shishir yadav

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.12 04:16:14