How To Deploy A Next App On Cpanel Using SSH


In This Blog, I will show you how to deploy next app in apache server or linux server Next.js has emerged as a popular framework for building React applications due to its efficiency and flexibility. Once you've developed your Next.js application, the next step is to deploy it onto a server to make it accessible to users worldwide. In this guide, we'll walk you through the process of deploying a Next.js application on a server

Prerequisites

Before you begin, make sure you have the following: A Next.js Application: Develop your Next.js application locally using Node.js and npm. A Server: This could be a apache server . SSH Access: Ensure you have SSH access to your server to upload files and execute commands remotely. 

Steps to Deploy Next.js Application


You can create a new Next.js project using the create-next-app command, which is provided by the Next.js team. Open your terminal and run the following command:



 npx create-next-app@latest 





After Creating a new project upload on the server below i will show you step step how deploy on your linux server

Step 1 : Go to file manager





Step 2 : Create a zip
file and upload under root location in your server


Step 3:
SSH login with server details you can use putty or command line
ssh username@host 

Then enter your password and go to project root location same you can use putty below i will show you in details.




type your host name and user name and password password you can not show in the cmd line simply copy the password then right in the cmd line



Step 4 : Go to the project location then run this command
npx next build
Step 5 : you can run with screen or pm2 command for deployment

Simply type screen then run next start command with port number or using pm2
screen 
npx next start -p 3099 

if you use pm2 type this command
pm2 start npm --name app1 -- run start -- -p 2090 
Deploying a Next.js application on a server requires careful planning and execution, but by following the steps outlined in this guide, you can successfully make your application accessible to users worldwide. Stay vigilant with maintenance and updates to ensure smooth operation in the long run
Previous Post Next Post

Contact Form