Deploying a Next.js 14 App on Hostinger VPS || Ubuntu: A Step-by-Step Tutorial
Akin Akin
386 subscribers
2,706 views
60

 Published On May 26, 2024

Connecting to Your VPS Using SSH - Start with establishing a secure connection to your VPS, ensuring a safe and exclusive access environment for your deployment.

Updating the VPS - Keep your server up to date with the latest packages and security patches to ensure optimal performance and security.
sudo apt-get update and sudo apt-get upgrade

Install Node.js:
For the latest Node.js versions, visit the official Node.js package manager installation guide: https://nodejs.org/en/download/packag...

Install git:
sudo apt-get install git-all

Install PM2
npm install pm2@latest -g

Install NGINX
sudo apt install nginx -y

Configure NGINX as a reverse proxy for your application. Create and edit a new configuration file:
sudo nano /etc/nginx/sites-available/yourappname.com

server {
    listen 80;
    server_name yourappname.com;

    location / {
        proxy_pass http://localhost:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}

Enable the configuration by creating a symlink and then test and reload NGINX:
sudo ln -s /etc/nginx/sites-available/yourappname.com /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx

Secure Your Application with SSL (HTTPS)
Install Certbot and the NGINX plugin:
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
sudo certbot --nginx -d yourappname.com

Open Necessary Ports in the Firewall
sudo ufw allow ssh
sudo ufw allow http
sudo ufw allow https
sudo ufw enable
sudo ufw status

For those looking for more details on deploying a MERN stack application on Hostinger VPS, check out my previous video for a comprehensive guide:    • Deploy MERN App with Hostinger VPS in...  

For the source code of the entertainment app being deployed, visit the GitHub repository: https://github.com/Akintola97/nextjs-...

Hashtags:
#Nextjs #HostingerVPS #WebDeployment #Ubuntu #SSL #Nginx #Nodejs #PM2

show more

Share/Embed