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

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 ...

Introduction to Cloud Computing: Revolutionizing the Digital Landscape

In today's rapidly evolving digital world, cloud computing stands as a cornerstone of modern technology, transforming how businesses operate and individuals interact with data. Let's dive deep into this fascinating technology that powers our digital future. ## What is Cloud Computing? Imagine having a virtual supercomputer at your fingertips, accessible from anywhere in the world. That's the essence of cloud computing – a technology that delivers computing services such as storage, databases, software, and processing power over the internet, eliminating the need for physical hardware investments. ## The Three Pillars of Cloud Service Models ### Infrastructure as a Service (IaaS) Think of IaaS as renting the digital building blocks of computing. Companies like Amazon Web Services (AWS) and Microsoft Azure provide virtual machines, storage, and networking resources on-demand. This model offers unprecedented flexibility, allowing businesses to scale their infrastructure up or ...

How to Fix "ERESOLVE Unable to Resolve Dependency Tree" Error While Creating a React App

How to Fix Dependency Errors While Creating a React App If you're trying to set up a React app using npx create-react-app and encounter the following error: npm error code ERESOLVE npm error ERESOLVE unable to resolve dependency tree npm error Found: react@19.0.0 npm error Could not resolve dependency: npm error peer react@"^18.0.0" from @testing-library/react@13.4.0 Don't worry! This issue occurs due to dependency conflicts between react , react-dom , and other packages like @testing-library/react . Below are two simple ways to fix this issue. Step 1: Try Fixing It With npm Before switching to Yarn, you can resolve the issue by installing the missing or incompatible dependencies manually. Here's how: After running npx create-react-app my-app , if the error appears, navigate to your project folder: cd my-app Install the missing web-vitals dependency: npm install web-vitals Check for other dependency ...