Building a Sample App with MERN Stack on AlmaLinux 8.6 VPS from Domain India Print

  • 0

This article will guide you through building a sample app using the MERN stack (MongoDB, Express.js, React, and Node.js) on an AlmaLinux 8.6 VPS purchased from Domain India. We'll also discuss configuring the app's functionality and setting up the environment for smooth deployment. The VPS used in this tutorial can be purchased from the following product URL:

1. A VPS running AlmaLinux 8.6 from Domain India
2. Basic knowledge of JavaScript, React, and Express.js
3. Access to the command line via SSH
4. Familiarity with Git and GitHub

Step 1: Set up AlmaLinux 8.6 VPS
Once you have purchased your VPS from Domain India, follow the instructions provided to set up AlmaLinux 8.6 on your server. After the setup is complete, connect to the server via SSH using the provided credentials.

Step 2: Install Node.js and NPM
To install Node.js and NPM on your server, run the following commands:

sudo dnf install -y gcc-c++ make
curl -sL | sudo -E bash -
sudo dnf install -y nodejs

Step 3: Install MongoDB
To install MongoDB, run the following commands:

sudo dnf install -y mongodb-org
sudo systemctl enable --now mongod

Step 4: Clone the Sample App
Clone the sample app repository from GitHub using the following command:

git clone

Step 5: Install Dependencies
Navigate to the project's root folder and install the required dependencies:

cd sample-mern-app
npm install
cd client
npm install

Step 6: Configure the App
Edit the configuration files in the `config` folder according to your requirements, including database credentials, API keys, and any other necessary configurations.

Step 7: Set up a Reverse Proxy with Nginx (optional)
To make the app accessible via a domain name, set up a reverse proxy using Nginx. First, install Nginx:

sudo dnf install -y nginx
sudo systemctl enable --now nginx

Create a new Nginx configuration file for your app:

sudo nano /etc/nginx/conf.d/sample-mern-app.conf

Add the following configuration, replacing `` with your actual domain name:

server {
listen 80;

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;

Save the file and restart Nginx:

sudo systemctl restart nginx

Step 8: Start the App
Navigate to the project's root folder and start the server:

cd sample-mern-app
npm start

In a separate terminal, start the React app:

cd client
npm start

You have successfully built a sample app using the MERN stack on an AlmaLinux 8.6 VPS from Domain India. You can now access the app via your domain name or the server's IP address. Remember to configure the app's functionality and 

environment for a smooth deployment experience. By following these steps, you have laid the foundation for developing and deploying more complex applications using the MERN stack.

Next Steps:
1. Secure your application by implementing authentication and authorization features.
2. Optimize the performance of your application by using caching mechanisms and minimizing resource usage.
3. Set up continuous integration and deployment (CI/CD) pipelines to streamline the development process.
4. Monitor your application using logging and analytics tools to identify and resolve any issues that may arise.
5. Regularly update your dependencies and address any security vulnerabilities that are discovered.

By focusing on these next steps, you can ensure that your MERN stack application is robust, secure, and maintainable, allowing you to scale it up as needed. The skills and knowledge you gain from building this sample app will provide a solid foundation for future projects, and the experience you gain from working with AlmaLinux 8.6 VPS will make you a more versatile developer.

Was this answer helpful?
« Back