Actual combat: teach you to deploy your own nodejs application step by step

Time:2020-7-20

Date: 2020-4-24

If you also have your own small website, your own domain name. Please let it run up and let it run through the Internet, WeChat's tiktok, the browser's leaving your footprints in this huge flow of information.

Next, I'll teach you to go online on your own website

If you finish reading this article, your website will be online. Please tell me, let me share this joy with you.

Look at the effect first

Online demo

catalog

  1. Key technical points
  2. Get started

    1. Purchase domain name, virtual machine
    2. Installing the production environment Suite
    3. Start your own project
    4. Write nginx configuration
    5. Restart nginx
    6. Configure domain name mapping
  3. summary
  4. Postscript

Key technical points

1. How to access my host through domain name (configure DNS resolution of domain name)
2. How to install the server suite MySQL nginx nodejs

How to access my host through domain name

In fact, this is the simplest step. Manufacturers who purchase domain names will have a domain name resolution page, such as Alibaba cloud's cloud resolution DNS

Actual combat: teach you to deploy your own nodejs application step by step

How to install the server suite MySQL nginx nodejs

The simplest way to install the pagoda linxu panel (graphic tool)
Official website: https://www.bt.cn/download/linux.html

It is suggested that you should not rely heavily on pagoda. You should learn Linux knowledge systematically before you can use the tools better. I will also publish some Linux articles later.

Get started

  1. Purchase domain name, virtual machine

    [domain name] I recommend Alibaba cloud, which is the largest cloud computing provider in China. I don’t recommend buying a. COM domain name. Like me xinglong.tech Only 199 yuan in 10 years.

Actual combat: teach you to deploy your own nodejs application step by step

[virtual machine] is a virtual computer. Cloud computing service providers will virtual a host to you from a super large computer. Domestic cloud computing manufacturers will assign you public network IP. I recommend buying a minimum configuration of 1 core 1GB memory, and Tencent cloud new users will get 99 yuan in the first year.

Actual combat: teach you to deploy your own nodejs application step by step

  1. Installing the production environment Suite

    1. Install pagoda Linux panel installation tutorial
    2. Graphical interface to install various software

Actual combat: teach you to deploy your own nodejs application step by step

  1. Start your own project

    Most projects start in a different way. Of course, you know how to start your own code. However, pay attention to configuring the production environment

  2. Write nginx configuration

    Let’s get started with the simplest nginx configuration

    1. Create a new file on your computer demo.conf
    2. Open this file to write

      server  {
          listen 80;
          server_ Name your domain name; ා attention!! It needs to be replaced here
      
          location / {
              proxy_set_header Upgrade $http_upgrade;
              proxy_set_header Connection "upgrade";
              proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
              proxy_set_header Host $host;
      
              proxy_ pass  http://localhost : the boot port of your project /; 
              #Attention!! It needs to be replaced here
          }
      }
    3. Upload this file to the / www / server / panel / Vhost / nginx / directory of your virtual machine
  3. Restart nginx

    1. Restart nginx to use the pagoda GUI. I still want to suggest that you learn nginx command, learn more about nginx knowledge, do not rely on graphical interface

Actual combat: teach you to deploy your own nodejs application step by step

Using ngixn common commands

$nginx ා start
$nginx - t ා test whether all nginx configurations are correct
$nginx - s reload ා restart nginx
$nginx - s stop ා stop nginx
  1. Configure domain name mapping

This is the easiest step.

Actual combat: teach you to deploy your own nodejs application step by step
Actual combat: teach you to deploy your own nodejs application step by step

After configuration, enter your domain name in the browser and try it. You should be able to visit your website.

summary

This is the simplest online process. If you are in trouble, I will help you Wx: guzhan321

We rely heavily on the pagoda when we install the program, but this is not a good habit. I still suggest that you visit the official website of each major software more to see the installation method and documentation of the official website

Nodejs official website: http://nodejs.cn/
Official website of MySQL: https://www.mysql.com/
Nginx website: http://nginx.org/

Postscript

It is a good learning method to consult the documents while fighting. Take this opportunity to open the official documentation of these tools, which are the best learning materials.

Get me

  • GitHub

Actual combat: teach you to deploy your own nodejs application step by step
Actual combat: teach you to deploy your own nodejs application step by step

Resource sharing:

  • Xshell free cracked version link: https://pan.baidu.com/s/1S_ TG… Extraction code: 5vgq
  • Navicat free cracked link: https://pan.baidu.com/s/1cj0W… Extraction code: qxfj

Recommended Today

Application of Linux page cache tuning in Kafka

This article starts with WeChat official account of vivo Internet technology.Link:https://mp.weixin.qq.com/s/MaeXn-kmgLUah78brglFkg Author: Yang Yijun This paper mainly describes the background of Linux page cache optimization, the basic concept of page cache, lists some solutions for the IO performance bottleneck of Kafka, how to adjust the relevant parameters of page cache, and the effect comparison before […]