Gatsby: Difference between revisions

Created page with "==Install NodeJS and NPM== There are some methods to install both NodeJS and NPM. In this article, we will install them using the node source. For other methods, you can check our blog post on how to install NodeJS and NPM. curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash - Once completed, we need to download the package information from the newly added source above. sudo apt update Next, run the following command to finally install NodeJS and NPM. s..."
 
No edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
==Install NodeJS and NPM==
==Install NodeJS and NPM==
There are some methods to install both NodeJS and NPM. In this article, we will install them using the node source. For other methods, you can check our blog post on how to install NodeJS and NPM.
There are some methods to install both NodeJS and NPM. In this article, we will install them using the node source. For other methods, you can check our blog post on how to install NodeJS and NPM.


Line 46: Line 47:


==Install PM2==
==Install PM2==
Process Manager (PM2) will allow you to keep applications alive forever, reload them without downtime, and facilitate common system admin tasks. Invoke the command below to install PM2 on your Ubuntu 20.04 globally.
Process Manager (PM2) will allow you to keep applications alive forever, reload them without downtime, and facilitate common system admin tasks. Invoke the command below to install PM2 on your Ubuntu 20.04 globally.


Line 57: Line 59:


==Install and Configure NGINX==
==Install and Configure NGINX==
Your Gatsby install has now been completed and you should be able to access it at your server’s public IP with port number 8000. However, if you want to access your Gatsby website using a domain name or subdomain name instead of typing the server’s IP address and the port number in the URL, you would need to configure a reverse proxy on your server.
Your Gatsby install has now been completed and you should be able to access it at your server’s public IP with port number 8000. However, if you want to access your Gatsby website using a domain name or subdomain name instead of typing the server’s IP address and the port number in the URL, you would need to configure a reverse proxy on your server.


Line 69: Line 72:
  sudo systemctl status nginx
  sudo systemctl status nginx


Once installed, create a new Nginx server block configuration file. Replace yourdomain.com with your actual domain or subdomain name:
Once installed, create a new Nginx server block configuration file. Replace yourdomain.com with your actual domain or subdomain name


  sudo nano /etc/nginx/sites-enabled/yourdomain.com.conf
  sudo nano /etc/nginx/sites-enabled/yourdomain.com.conf
Line 79: Line 82:
     listen 80;
     listen 80;
   
   
    server_name yourdomain.com;
 
    location / {
    server_name yourdomain.com;
        proxy_pass http://localhost:8000;
    location / {
        proxy_http_version 1.1;
        proxy_pass http://localhost:8000;
        proxy_set_header X-Forwarded-Host $host;
        proxy_http_version 1.1;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Host $http_host;
        proxy_set_header Connection "Upgrade";
        proxy_set_header Upgrade $http_upgrade;
        proxy_pass_request_headers on;
        proxy_set_header Connection "Upgrade";
    }
        proxy_pass_request_headers on;
    location ~ /.well-known {
    }
        allow all;
    location ~ /.well-known {
    }
      allow all;
    }
  }
  }
   
   
Save the file by pressing ''CTRL + O'' then press ''CTRL + X'' to exit the nano editor then restart [[Nginx]].
Save the file by pressing ''CTRL + O'' then press ''CTRL + X'' to exit the nano editor then restart [[Nginx]].