惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - Franky
云风的 BLOG
云风的 BLOG
人人都是产品经理
人人都是产品经理
博客园 - 叶小钗
Engineering at Meta
Engineering at Meta
Vercel News
Vercel News
Y
Y Combinator Blog
B
Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Check Point Blog
M
MIT News - Artificial intelligence
Jina AI
Jina AI
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Apple Machine Learning Research
Apple Machine Learning Research
Hugging Face - Blog
Hugging Face - Blog
阮一峰的网络日志
阮一峰的网络日志
罗磊的独立博客
Stack Overflow Blog
Stack Overflow Blog
F
Fortinet All Blogs
博客园 - 司徒正美
I
InfoQ
Google DeepMind News
Google DeepMind News
GbyAI
GbyAI
U
Unit 42

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
How to Deploy a Next.js App on cPanel Shared Hosting (Beg...
Waseem Akram · 2026-06-23 · via DEV Community

Waseem Akram

If you have a shared hosting account with cPanel and want to run a Next.js website on your own domain, this guide will help you do it step by step.

I created this guide for beginners, so even if you have never deployed a Next.js project before, you should be able to follow along.

===========Quick Summary (For Experienced Developers)========

If you're already familiar with Next.js and cPanel, here's the short version:

✅ Build the project on your local computer npm run build

✅ Remove unnecessary files before uploading node_modules, .git, .next/cache

✅ Create a Node.js Application in cPanel

✅ Upload your project files

✅ Run: npm install

✅ Configure startup file (app.js or server.js)

✅ Restart the Node.js application

✅ Open your domain and test

If you need detailed instructions, continue reading below.

=================================================================

Why Deploy Next.js on Shared Hosting?

Many developers use platforms like Vercel for Next.js hosting. However, some clients already have shared hosting and don't want to purchase a VPS or additional hosting.

If your hosting provider supports Node.js in cPanel, you can run a Next.js application directly from your hosting account.

Note: Shared hosting is usually slower than VPS or cloud hosting. It works best for small projects, personal websites, staging environments, or low-traffic applications.

Requirements

Before starting, make sure you have:

  • A Next.js project
  • cPanel access
  • Node.js Application feature enabled
  • A domain or subdomain connected to your hosting account

Step 1: Build Your Next.js Project Locally

Do not build the project on shared hosting.

Open your terminal and run:

npm run build

This creates an optimized production build.

Step 2: Clean the Project Before Uploading

Uploading unnecessary files makes deployment slower.

You can safely remove:

node_modules
.git
.next/cache

Keep these folders:

.next
public
src
app
pages
package.json

This reduces upload size significantly.

Step 3: Create a Node.js Application in cPanel

Login to cPanel.

Navigate to: Software -> Setup Node.js App

Click: Create Application

Choose:

  • Node.js version (latest available)
  • Domain or subdomain
  • Application root directory

Save the application.

After creation, cPanel will generate the startup environment for your app.

Step 4: Upload Your Project Files

Open: cPanel → File Manager

Upload your project as a ZIP file.

After uploading:

  1. Extract the ZIP.
  2. Move files into the application root directory.
  3. Verify that package.json is visible.

Your structure should look similar to:

my-app/
├── .next/
├── public/
├── package.json
├── app.js

Step 5: Install Dependencies

Return to the Node.js Application page.

Install project dependencies: npm install

Wait until installation completes.

Do NOT run: npm run dev

The development server should never be used in production.

Step 6: Configure the Startup File

Your hosting provider may require a startup file such as:

app.js or server.js

This file starts the Next.js application and handles incoming requests.

If your hosting provider automatically creates an app.js file, update it according to your hosting requirements.

Step 7: Restart the Application

After uploading files and installing dependencies:

  • Stop the application
  • Start it again

or click: Restart inside cPanel.

Step 8: Test Your Website

Open your domain in a browser.

If everything is configured correctly, your Next.js application should load successfully.

Example: https://yourdomain.com

=========================== ## Common Problems ====================

  1. Website Shows 500 Error

Check:

  • package.json exists
  • dependencies installed
  • startup file path is correct
  1. Build Not Found Error

Make sure you ran: npm run build

before uploading.

The .next folder must be uploaded.

  1. Node.js Option Missing in cPanel

Some shared hosting plans do not support Node.js.

Contact your hosting provider and ask whether Node.js Applications are available.

Final Thoughts

Deploying Next.js on cPanel is possible when your hosting provider supports Node.js. While shared hosting is not the ideal environment for large Next.js applications, it works well for testing, personal projects, small business websites, and staging environments.

If your project starts receiving significant traffic, consider moving to a VPS Hosting or a platform designed specifically for Next.js hosting.

Happy Deploying!