Skip to main content

How to Deploy a Next.js SSR App on MilesWeb VPS (AlmaLinux 8.10)

🚀 How to Deploy a Next.js SSR App on MilesWeb VPS (AlmaLinux 8.10)

If you're building a Next.js SSR (Server-Side Rendering) app and want to host it on your MilesWeb VPS with AlmaLinux 8.10, this guide is all you need. Follow these clear steps to get your project live and production-ready.


🛠️ Prerequisites

  • VPS with AlmaLinux 8.10 (MilesWeb)
  • Root or sudo access to the server
  • Your Next.js project (with app/page.js structure)
  • Domain (optional but recommended)

🔐 Step 1: Connect to Your Server

ssh root@your-server-ip
Update your system:
dnf update -y

📦 Step 2: Install Node.js and Git

Install Node.js LTS (e.g., v18):
curl -fsSL https://rpm.nodesource.com/setup_18.x | bash -
dnf install -y nodejs
Check versions:
node -v
npm -v
Install Git if needed:
dnf install git -y

📁 Step 3: Upload or Clone Your Project

Option 1: Clone from GitHub
cd /var/www
git clone https://github.com/your-repo.git my-next-app
cd my-next-app
Option 2: Upload from Your Laptop (via SCP)
scp -r /path/to/your/project root@your-server-ip:/var/www/my-next-app

⚙️ Step 4: Install & Build Your App

Go to the project folder:
cd /var/www/my-next-app
Install dependencies:
npm install
Build the Next.js app:
npm run build
Start it (for testing):
npm start

🔁 Step 5: Use PM2 to Keep It Running

Install PM2:
npm install -g pm2
Start the app with PM2:
pm2 start npm --name "my-next-app" -- start
pm2 save
pm2 startup

🌐 Step 6: Set Up Nginx Reverse Proxy

Install Nginx:
dnf install nginx -y
systemctl enable nginx
systemctl start nginx
Create Nginx config:
nano /etc/nginx/conf.d/my-next-app.conf
Paste this:
server {
    listen 80;
    server_name your-domain.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;
    }
}
Test and reload:

nginx -t
systemctl restart nginx

🔒 Step 7: Add Free SSL (Let's Encrypt)

Install Certbot:

dnf install epel-release -y
dnf install certbot python3-certbot-nginx -y
Issue a certificate:

certbot --nginx -d your-domain.com
Auto-renew:

echo "0 0 * * * root certbot renew --quiet" >> /etc/crontab

✅ Your Next.js SSR App is Live!

You can now visit your domain and enjoy your deployed Next.js app running smoothly on your MilesWeb VPS with AlmaLinux 8.10.


💡 Tips & Extras

  • Use .env.production for environment variables
  • Use pm2 logs to monitor your app
  • Block unused ports with a firewall

Need help? Drop your questions in the comments or contact your server provider. Happy deploying! 🚀

Comments

Popular posts from this blog

How to Convert a Next.js Website into a PWA and TWA

🚀 Complete Guide: Converting Next.js to PWA & TWA Transform your Next.js website into a Progressive Web App and wrap it as an Android application using Trusted Web Activity. Every step explained in detail! 📋 Table of Contents What is a PWA? What is a TWA? Prerequisites & Setup Step 1: Convert Next.js to PWA Install Dependencies Configure next.config.js Create Web App Manifest Prepare App Icons Update Document Head Build and Test PWA Step 2: Wrap PWA as TWA Create Asset Links File Install Bubblewrap CLI ...

DevOps Best Practices

 # DevOps Best Practices: Your Ultimate Guide to Modern Software Development In today's fast-paced tech world, DevOps isn't just a buzzword – it's a game-changer. Let's dive into the essential practices that can transform your software development process. ![DevOps Lifecycle](https://blogger.googleusercontent.com/img/placeholder.png) ## 🔄 1. Continuous Integration (CI) - The Foundation Think of CI as your code's quality guardian. Every time developers push code, automated tests run to catch issues early. Here's what makes great CI: - Automated builds triggered with every commit - Comprehensive test suites running automatically - Code quality checks integrated into the pipeline - Quick feedback loops to developers **Pro Tip:** Start with simple automated tests and gradually build up your test suite. Remember, it's better to have a few reliable tests than many unreliable ones. ## 🚀 2. Continuous Delivery (CD) - From Code to Customer CD ensures your software ...

Ultimate Guide to Sending Data in React: Axios & Fetch Explained

Ultimate Guide to Sending Data in React using Axios and Fetch Whether you're building a login form, uploading files, or submitting a complex dataset to your backend, understanding how to send data in React is essential. In this comprehensive guide, we'll explore all the major ways to send data using Axios and the native Fetch API , including formats like JSON , form-data , x-www-form-urlencoded , and other advanced techniques. This guide is designed for developers from beginner to advanced levels, providing both theoretical understanding and practical implementation examples. By the end of this tutorial, you'll have a complete understanding of how data flows from React components to backend servers, and you'll know exactly which method to choose for different scenarios. 📌 Why Learn Different Data Formats? Before diving into implementation details, it's crucial to understand why different data formats exist...