Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

Sorry, you do not have permission to ask a question, You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please type your username.

Please type your E-Mail.

Please choose an appropriate title for the post.

Please choose the appropriate section so your post can be easily searched.

Please choose suitable Keywords Ex: post, video.

Browse

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Logo Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Logo

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Navigation

  • Home
  • About Us
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • About Us
  • Contact Us
Home/ Questions/Q 2083

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Latest Questions

Author
  • 61k
Author
Asked: November 26, 20242024-11-26T02:09:07+00:00 2024-11-26T02:09:07+00:00

Production deployment Strapi + Gatsby app on VPS Shared Hosting: installing Node & Creating configs. (2)

  • 61k

Welcome to the second part of the production deployment of the Strapi + Gatsby app on VPS Shared Hosting! πŸ™Œ


Before install Node, you need to connect to the server over SSH. You can find all the data for connecting via SSH on your host.

So, in your terminal enter:

shh root@00.0.000.000 
Enter fullscreen mode Exit fullscreen mode

Instead “00.0.000.000” enter your server IP. After enter password.

Installing Node

In order to install Node, you need to find out what OS installed on the your server.

In different hosts it can be find out on different ways.
So, you need to find out it in your case πŸ€—

In my case, the server had Cent OS installed and I'll show you how I installed Node on this OS.

For different OS Node has some great documentation πŸ‘

let's continue.

First install yum:

curl -sL https://rpm.nodesource.com/setup_10.x | sudo bash - 
Enter fullscreen mode Exit fullscreen mode

Then install Node:

sudo yum install nodejs 
Enter fullscreen mode Exit fullscreen mode

That's it!
You can check out the Node version:

node --version 
Enter fullscreen mode Exit fullscreen mode

Adding new domain and subdomain

To add a domain to VestaCP you must:
Log in to control panel and go to the section Web.
vesta menu
In the upper left corner click on Add Web Domain. Fill in all the required fields and click Add.
add domain
Also you need to create a subdomain. The procedure for creating a subdomain is the same as for a domain.

When you're enter your domain name, you need to write “admin.” in front of it.
It looks like this: admin.your-domain.com.

In the future, we will install the Strapi backend on a subdomain.

Adding template for nginx in VestaCP

Templates for nginx on a server with VestaCP installed are stored along the path: /usr/local/vesta/data/templates/web/nginx/.

Each template must be provided in two formats:

  1. *.tpl – for http
  2. *.stpl – for ssl(https)

The file names must be the same.

Let's create them:

nodeproxy.stpl

server {   listen   %ip%:%proxy_port%;   server_name %domain_idn% %alias_idn%;   error_log /var/log/%web_system%/domains/%domain%.error.log error;    location /error/ {     alias  %home%/%user%/web/%domain%/document_errors/;   }    location @fallback {     proxy_pass   http://%ip%:%web_port%;   }    location ~ /.ht  {return 404;}   location ~ /.svn/ {return 404;}   location ~ /.git/ {return 404;}   location ~ /.hg/  {return 404;}   location ~ /.bzr/ {return 404;}    include %home%/%user%/conf/web/nginx.%domain%.conf*; } 
Enter fullscreen mode Exit fullscreen mode

nodeproxy.tpl

server {   listen   %ip%:%proxy_port%;   server_name %domain_idn% %alias_idn%;   error_log /var/log/%web_system%/domains/%domain%.error.log error;    location /error/ {     alias  %home%/%user%/web/%domain%/document_errors/;   }    location @fallback {     proxy_pass   http://%ip%:%web_port%;   }    location ~ /.ht  {return 404;}   location ~ /.svn/ {return 404;}   location ~ /.git/ {return 404;}   location ~ /.hg/  {return 404;}   location ~ /.bzr/ {return 404;}    include %home%/%user%/conf/web/nginx.%domain%.conf*; } 
Enter fullscreen mode Exit fullscreen mode

After adding a template in the domain settings panel, you need to select a template for nginx:
domain settings panel
All the above steps must be repeated for the subdomain.

After editing the nginx configurations, it must be restarted for the changes to take effect!

For that go to the “Server” on top menu of VestaCP:
top menu
There you'll see nginx. Move mouse on it end click restart.

Nginx configuration

After applying the template for nginx, configuration files will be automatically generated under the path /home/{username}/conf/web. Let's take a closer look at the contents of the template, namely, we are interested in the line:

include /home/username/conf/web/nginx.example.com.conf*; 
Enter fullscreen mode Exit fullscreen mode

Since nginx configuration files are dynamic, we cannot change their content, otherwise we will lose the changes after regenerating the template. But we can create an nginx.example.com.conf* file to be extracted. It is worth noting that we only have access to the server block of the configuration file, since include is done there. This is done because the server block should be generated automatically and have basic settings.

So let's create files for main domain:

snginx.example.com.conf*

Empty 
Enter fullscreen mode Exit fullscreen mode

nginx.example.com.conf*

if ( $scheme = "http" ) {  rewrite ^/(.*)$ https://$host/$1 permanent; } 
Enter fullscreen mode Exit fullscreen mode

The code above redirects the request from http to https.

Now create files for subdomain:

snginx.admin.example.com.conf*

location / {    proxy_pass http://00.0.000.000:1337; } 
Enter fullscreen mode Exit fullscreen mode

Instead 00.0.000.000 your server IP.

nginx.admin.example.com.conf*

if ( $scheme = "http" ) {  rewrite ^/(.*)$ https://$host/$1 permanent; } 
Enter fullscreen mode Exit fullscreen mode


That's it! 😞

In next part we will deploy Gatsby and Strapi, create web hooks and install pm2.

If you want to add something, drop it in the commentsπŸ‘‡πŸ»

gatsbyjavascriptreactwebdev
  • 0 0 Answers
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

Sidebar

Ask A Question

Stats

  • Questions 4k
  • Answers 0
  • Best Answers 0
  • Users 2k
  • Popular
  • Answers
  • Author

    ES6 - A beginners guide - Template Literals

    • 0 Answers
  • Author

    Understanding Higher Order Functions in JavaScript.

    • 0 Answers
  • Author

    Build a custom video chat app with Daily and Vue.js

    • 0 Answers

Top Members

Samantha Carter

Samantha Carter

  • 0 Questions
  • 20 Points
Begginer
Ella Lewis

Ella Lewis

  • 0 Questions
  • 20 Points
Begginer
Isaac Anderson

Isaac Anderson

  • 0 Questions
  • 20 Points
Begginer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help

Footer

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise

Querify Question Shop: Explore, ask, and connect. Join our vibrant Q&A community today!

About Us

  • About Us
  • Contact Us
  • All Users

Legal Stuff

  • Terms of Use
  • Privacy Policy
  • Cookie Policy

Help

  • Knowledge Base
  • Support

Follow

© 2022 Querify Question. All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.