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
Step 1 : Go to file manager
Step 3: SSH login with server details you can use putty or command line
ssh username@host
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 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
if you use pm2 type this command
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
screen
npx next start -p 3099
pm2 start npm --name app1 -- run start -- -p 2090
Tags:
Next Js