如何在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.
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 --prodin your Angular project folder. This generates adistdirectory with optimized, production-ready files. - Upload & Extract: Compress the
distfolder into a ZIP file. Log into cPanel, open File Manager, navigate to your domain’s root directory (usuallypublic_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
.htaccessfile inpublic_htmlwith this code to ensure all routes redirect toindex.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 outsidepublic_htmlfor 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
- Application root: A folder name (e.g.,
- 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
localhostand 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 --prodto generate thedistfolder, 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
.htaccessfile 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 outsidehttpdocsor 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
- Document root: Choose a folder (e.g.,
- 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
localhostand 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
755and file permissions to644(avoid777—it’s a major security risk). - Angular Optimization: Never skip the
--prodflag when building—this reduces file size drastically and improves load times.
内容的提问来源于stack exchange,提问作者shishir yadav
相关产品推荐
相关产品推荐

