Deploying a Next.js 14 App on Hostinger VPS || Ubuntu: A Step-by-Step Tutorial

  Рет қаралды 2,294

Akin

Akin

Күн бұрын

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: nodejs.org/en/...
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 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 H...
For the source code of the entertainment app being deployed, visit the GitHub repository: github.com/Aki...
Hashtags:
#Nextjs #HostingerVPS #WebDeployment #Ubuntu #SSL #Nginx #Nodejs #PM2

Пікірлер: 10
@bilbyplaisir9413
@bilbyplaisir9413 3 ай бұрын
Always the first one to comment ✅👍great video 😊
@Akin_37
@Akin_37 3 ай бұрын
Thank you... Appreciate it.
@Jitendra100
@Jitendra100 Ай бұрын
Good but I was just thinking why do you close your guide steps video while you open it again and again
@Franco123787
@Franco123787 Ай бұрын
Does this guide cover all the security issues to consider when deploying an app on a VPS? For example, to be protected against DDoS attacks and all those kinds of problems? Thank you!
@Akin_37
@Akin_37 Ай бұрын
Hi, Unfortunately not. With attacks such as ddos, its better to use AWS cloud service (or something similar) to aid in deployment. As AWS has tools such as AWS Shield that can help with this issue. Other third party apps can be used as well. Im not too well versed in that department so i wouldn't know the best third party options to recommend. Other configurations within Nginx can be made to help as well. But like i stated, i'm not, as of this moment, too well versed in creating an environment that would prevent such attacks. The best thing i can recommend would be to use AWS or similar cloud service.
@entoni-os
@entoni-os Ай бұрын
Hello Akin! Thank you for great video. I had some problems I like to share: 1. Ssh wasn't working on fresh ubuntu server. Solution is to run 'sudo ssh-keygen -A' command 2. Nginx wasn't working because apache2 took port 80. Solution is to stop apache2 service 3. After enabling uwf nothing was working. Solution is to reboot VPS. All the best :)
@Akin_37
@Akin_37 Ай бұрын
Hi there, so in order to help further, would you be able to explain what exactly you're trying to accomplish? Are you attempting to deploy a next js app? what db are you using as well? is this a hostinger vps (not that this part matters much as long as its an ubuntu vps)... Answers to this will help when i try to help you debug. Lastly when you follow the steps when exactly do you run into errors?
@entoni-os
@entoni-os Ай бұрын
I successfully deployed a Next.js app using your video, but I encountered some issues during the process that were not directly related to Next.js and/or the procedure you explained. Overall, everything went smoothly. I used a Hostinger VPS with an external domain that is not on Hostinger and cannot be transferred because Hostinger does not support it, specifically a .hr domain. After setting up the VPS (Ubuntu 22), I couldn't access the VPS via SSH from my personal computer. I had to run the command 'sudo ssh-keygen -A' to configure SSH. In the last step of configuring nginx, specifically 'sudo systemctl reload nginx', I realized that the nginx service wasn't running because, by default, Ubuntu has the apache2 server configured to listen on port 80, so I had to stop and disable it to start nginx. The last problem occurred after I enabled the firewall, i.e., 'sudo ufw enable'. After that, I couldn't access either the website or the VPS via SSH. The solution was to reboot the VPS, probably to set up networking, I'm not exactly sure why, but after that, everything worked. Both website access and VPS access via SSH were restored.
@Akin_37
@Akin_37 Ай бұрын
@@entoni-os That's interesting lol... Sometimes all it takes is a reboot lol. Glad the application ended up working well for you.
Next.js 14 Deployment to VPS with GitHub Actions CI/CD
52:31
Секрет фокусника! #shorts
00:15
Роман Magic
Рет қаралды 117 МЛН
отомстил?
00:56
История одного вокалиста
Рет қаралды 6 МЛН
Nastya and balloon challenge
00:23
Nastya
Рет қаралды 57 МЛН
How To Deploy Next.js ECommerce On Ubuntu Hostinger VPS [4k]
25:04
Coding with Basir
Рет қаралды 1,1 М.
Your own Vercel on VPS - Coolify
14:07
Hitesh Choudhary
Рет қаралды 7 М.
The BEST way to host Next.js websites
17:37
ByteGrad
Рет қаралды 45 М.
Serverless might bankrupt you (and how to deploy to a VPS instead)
14:26
How To Deploy NextJS With Nginx and PM2
16:43
Full Stack Book
Рет қаралды 46 М.
Dockerize Next.js & Deploy to VPS (EASY!)
19:43
ByteGrad
Рет қаралды 59 М.
Секрет фокусника! #shorts
00:15
Роман Magic
Рет қаралды 117 МЛН