Node.js/React.js Deployment To VPS Server

Node.js/React.js Deployment To VPS Server and SSL Icon
in this page you can uplode your app in vps server like DigitalOcean, Bluehost ,HostGator ,Hostinger ,Kamatera ,LiquidWeb, UltaHos, A2 Hosting ,Scala Hosting ,InMotion

To summarize everything in a video, click here
after you pay your server vps, complete step by stub

  1. download putty to connect your server
  2. click here to download putty
    now write your ip in putty and enter username and password

  3. Install Node/NPM
  4. To get this version, you can use the apt package manager. Refresh your local package index first:
    sudo apt update
    Then install Node.js:
    sudo apt install nodejs
    Check that the install was successful by querying node for its version number:
    node -v
    Output
    v10.19.0// or more
    If the package in the repositories suits your needs, this is all you need to do to get set up with Node.js. In most cases, you’ll also want to also install npm , the Node.js package manager. You can do this by installing the npm package with apt :
    sudo apt install npm
    This allows you to install modules and packages to use with Node.js. At this point, you have successfully installed Node.js and npm using apt and the default Ubuntu software repositories. The next section will show how to use an alternate repository to install different versions of Node.js.

  5. upload your project
  6. you have two ways
    • Clone your project from Github
    • There are a few ways to get your files on to the server, I would suggest using Git
      git clone yourproject.git

    • use FileZilla Client
    • click here to download FileZilla

  7. Install dependencies and test app
  8. cd yourproject
    npm install
    npm start (or whatever your start command)
    # stop app
    ctrl+C

  9. Setup PM2 process manager to keep your app running
  10. sudo npm i pm2 -g
    pm2 start app (or whatever your file name)

    # Other pm2 commands
    pm2 show app
    pm2 status
    pm2 restart app
    pm2 stop app
    pm2 logs (Show log stream)
    pm2 flush (Clear logs)

    # To make sure app starts when reboot
    pm2 startup ubuntu
    You should now be able to access your app using your IP and port. Now we want to setup a firewall blocking that port and setup NGINX as a reverse proxy so we can access it directly using port 80 (http)

  11. Install NGINX and configure
  12. sudo apt install nginx
    sudo nano /etc/nginx/sites-available/default
    Add the following to the location part of the server block
    server_name yourdomain.com www.yourdomain.com;

    location / {
    proxy_pass http://localhost:5000; #whatever port your app runs on
    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;
    }

    after edit click Ctrl+s to save and Ctrl+x to exit
    # Check NGINX config
    sudo nginx -t

    # Restart NGINX
    sudo service nginx restart
    You should now be able to visit your IP with no port (port 80) and see your app. Now let's add a domain

  13. Add domain in your Hosting
  14. Add domain in your Hosting

  15. Add your IP in your Domain like godaddy
  16. Add your IP in your Domain like godaddy
الدرس الاول شرح رفع تطبيق nodejs او react بشكل كامل على server VPS


الدرس الثاني شرح ربط الdomain الخاص بك ب server VPS


next to Add Configuring SSL Certificate

created by saleh hammudeh