Next.js + MySQL → cPanel Deployment
My setup:
Next.js (Frontend + Backend)
↓
Prisma
↓
MySQL
↓
cPanel
1. cPanel MySQL
Create a new DB and user from:
cPanel → MySQL Databases
Example:
DB: numberle_11
User: numberle_11
Host: 127.0.0.1
Port: 3306
Production DATABASE_URL:
mysql://numberle_11:PASSWORD@127.0.0.1:3306/numberle_11
2. Create Node.js App
Go to:
cPanel → Setup Node.js App
Example:
Node.js: 20
Application: https://11numberleathershoes.com
Root: /home/numberle/11numberleathershoes
Startup file: server.js
Node virtual environment:
/home/numberle/nodevenv/11numberleathershoes/20/bin/activate
3. Required Project Files
Don't only upload .next.
Make sure the project has:
.github/workflows/deploy.yml
scripts/cpanel-build.sh
server.js
package.json
prisma/schema.prisma
package.json:
"scripts": {
"start": "node server.js"
}
4. GitHub Secrets
GitHub:
Repository
→ Settings
→ Secrets and variables
→ Actions
Server — reusable
CPANEL_HOST = 65.181.111.182
CPANEL_USERNAME = numberle
CPANEL_PORT = 22
CPANEL_SSH_KEY
CPANEL_SSH_PASSPHRASE
Don't use CPANEL_PASSWORD because this workflow uses SSH key authentication.
Application-specific
CPANEL_APP_PATH =
/home/numberle/11numberleathershoes
CPANEL_NODEVENV =
/home/numberle/nodevenv/11numberleathershoes/20/bin/activate
ENV_DATABASE_URL =
mysql://numberle_11:PASSWORD@127.0.0.1:3306/numberle_11
ENV_AUTH_SECRET =
<random-secret>
ENV_NEXT_PUBLIC_SITE_URL =
https://11numberleathershoes.com
For another app, change:
CPANEL_APP_PATH
CPANEL_NODEVENV
ENV_DATABASE_URL
ENV_AUTH_SECRET
ENV_NEXT_PUBLIC_SITE_URL
5. Prisma
If Prisma's Rust engine crashes on the cPanel server, use the Node/MariaDB adapter.
prisma/schema.prisma:
generator client {
provider = "prisma-client-js"
engineType = "client"
}
Install:
npm install @prisma/client@6 @prisma/adapter-mariadb@6
npm install -D prisma@6
Generate:
npx prisma generate
6. Shared Prisma Client
Create:
src/lib/prisma.js
Use PrismaMariaDb adapter and export one shared Prisma client.
Then search the project for:
new PrismaClient()
Replace all bare instances with the shared client.
7. Deployment
Push to GitHub:
git add .
git commit -m "deploy"
git push
Then:
GitHub
↓
GitHub Actions
↓
SSH → cPanel
↓
Build Next.js
↓
Start/restart Node.js app
Check the application at:
https://11numberleathershoes.com
Quick Checklist
✓ MySQL DB created
✓ Node.js App created
✓ Startup = server.js
✓ Node version = 20
✓ CPANEL_PORT = 22
✓ SSH key configured
✓ App path correct
✓ Nodevenv path correct
✓ DATABASE_URL uses 127.0.0.1:3306
✓ Prisma adapter configured
✓ npx prisma generate works
✓ GitHub Actions succeeds
0 comments: