Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 

Repository files navigation

VPS SETUP

digital ocen ssl mongodb install

STEP 1

  
   ssh root@your_ip_adress
  

Then enter your password

STEP 2

Updated backdated packges

  
   sudo apt update
  
  
   sudo apt upgrade
  

STEP 3

Enabling and Configuring UFW (Uncomplicated Firewall)

  
   sudo ufw enable
  
  
   sudo ufw allow 22
  

Check allow port status

  
   sudo ufw status
  

STEP 3

Install NVM & Node.js

  
  curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
  
  source ~/.bashrc
  
    nvm -v
    nvm install --lts
    nvm install 18.17.1 (for specific version)
    node -v
    npm -v
  

Note: If version not showing please close the terminal and try again

STEP 4

git hub connection

  
    ls -al ~/.ssh
  
  
    ssh-keygen -t rsa -b 4096 -C "github@smtech24.com"
  
  
    eval "$(ssh-agent -s)"
  
  
    cat ~/.ssh/id_rsa.pub
  

Then copy the ssh key and pas it on your SSH and GPG kesy on your git hub clik new ssh key and write project name and past the key

  
   ssh -T git@github.com
  

STEP 5

Setup nginx

  
    sudo ufw allow 80/tcp
    sudo ufw allow 3000
    sudo ufw allow 443/tcp
    sudo ufw reload
    sudo apt install nginx -y
    sudo systemctl status nginx
    sudo systemctl start nginx
    sudo systemctl enable nginx
    sudo ufw allow 'Nginx Full'
    sudo ufw enable
  

need database configaration before step 6

STEP 6

Configure nginx

  
    sudo nano /etc/nginx/sites-available/yourdomain.com
    #this is for next js
    server {
    listen 80;
    server_name yourdomain.com www.yourdomain.com;
    location / {
        proxy_pass http://localhost:3000; # Next.js runs on port 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;
        }
    } 
    sudo ln -s /etc/nginx/sites-available/yourdomain.com /etc/nginx/sites-enabled

    #this is backend server setup
    server{
        listen 80;
        server_name api.myfinancialtrading.com;

        location / {
                proxy_pass  http://localhost:3000;
            # Add other proxy settings if needed
               proxy_set_header Host $host;
               proxy_set_header X-Forwarded-Host $host;
               proxy_set_header X-Forwarded-Proto $scheme;
               proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
     }


   ##For Websocket

  sudo nano etc/nginx/conf.d/file.conf


   
    server{
        listen 80;
        server_name api.myfinancialtrading.com;
           client_max_body_size 1000M;

      location / {
             proxy_pass http://localhost:5008;
             
             # WebSocket-specific headers
             proxy_http_version 1.1;                 
             proxy_set_header Upgrade $http_upgrade; 
             proxy_set_header Connection "Upgrade";  
         
             # Additional proxy headers
             proxy_set_header Host $host;                    
             proxy_set_header X-Forwarded-Host $host;      
             proxy_set_header X-Forwarded-Proto $scheme;     
             proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
         
             # Optional: Disable caching for WebSocket connections
             proxy_cache_bypass $http_upgrade; # Ensures that WebSocket connections are not cached.
         }

     }
    
    sudo ln -s /etc/nginx/sites-available/api.yourdomain.com /etc/nginx/sites-enabled
    sudo nginx -t
    sudo systemctl reload nginx
  

create folder

  
    sudo mkdir -p /var/www
  
  
    ls -l /var/www
  

STEP 7

Install Project & Setup

  
    git clone 
    npm install
    npm run build
    npm run start
    npm install -g pm2
    pm2 --version
      pm2 start npm --name "project-frontend" -- start (for next js frontend)
      pm2 start dist/server.js --name bigmama-backend (for backend)
    pm2 list
    pm2 startup
    pm2 save
    pm2 restart all (restart)
      pm2 stop nextjs-app (stop server)
      pm2 delete nextjs-app (delete server)
  

STEP 8

Create replica

  
     sudo ufw allow 27017 
     sudo nano /etc/mongod.conf 


   replication:
    replSetName: "rs0"

   sudo systemctl restart mongod
     mongosh
     rs.initiate()

   ## for env 
     DATABASE_URL="mongodb://127.0.0.1:27017/kumba?replicaSet=rs0"
   
    
  

STEP 9

Install SSL

  
    sudo apt install certbot python3-certbot-nginx -y
    sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com
  

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors