First of all, you need to run a command in your Next.js project: delete the old .next directory and run npm run build
Next Step : ->
After that, the newly created .next directory needs to be converted into a zip file.
After that, you need to copy the server's SSH, open the command prompt, and connect to the server.
Now you need to install npm, Node.js, and PM2 on it. The commands are like this:
Commands : -->
1 . Update your VPS :
sudo apt update
sudo apt upgrade -y
2 . Install Node.js and npm
# Install NodeSource PPA
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
# Install Node.js (includes npm)
sudo apt install -y nodejs
Check installation:
node -v
npm -v
Install PM2 (Process Manager for Node apps)
sudo npm install -g pm2
Check PM2 version:
pm2 -v
After all this, you need to go to your main directory and create a file there.
package.json
And in this file, copy and paste your project's package.json, but make sure to leave out the devDependencies
And now, go back to the CMD and run the npm install command
Notes : Now, in your VPS server's project directory, a node_modules folder will be created.
Now, in the same directory, you need to upload your Next.js build zip file.
And after extracting it, you need to move the .next folder outside into the main project directory.
And after that, you need to start the project with pm2 start npm -- start
Congratulations, now your website is live. Point your domain and you can check your website.
© 2025 WWW.WORLDTALKING.COM