Practice: step by step to teach you to deploy your nodejs application

Time:2020-6-24

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

If you have read this article, your website is online. Please tell me, let me share this joy with you.

First look at the effect

Online demo

catalog

  1. Key technology points
  2. Get started

    1. Purchase domain name, virtual machine
    2. Install production environment Kit
    3. Start your own project
    4. Writing nginx configuration
    5. Restart nginx
    6. Configure domain name mapping
  3. summary
  4. Postscript

Key technology points

1. How to access my host through domain name (configure domain name DNS resolution)
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. The manufacturer who purchases the domain name will have a domain name resolution page, such as Alibaba cloud's cloud DNS resolution

Practice: step by step to teach you to deploy your nodejs application

How to install the server suite MySQL nginx nodejs

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

It is recommended not to rely heavily on pagoda, but to learn Linux knowledge systematically, so as to use tools better. I will also post some Linux articles later.

Get started

  1. Purchase domain name, virtual machine

    [domain name] I recommend Alibaba cloud, the largest cloud computing provider in China. I don’t recommend buying. Com’s own domain name. Like me xinglong.tech It’s only 199 yuan in 10 years.

Practice: step by step to teach you to deploy your nodejs application

[virtual machine] is a virtual computer. The cloud computing service provider will provide you a virtual host from a super large computer, and the domestic cloud computing manufacturers will allocate public IP to you. I recommend buying the minimum 1-core 1GB of memory, and Tencent cloud new users will spend 99 yuan in the first year.

Practice: step by step to teach you to deploy your nodejs application

  1. Install production environment Kit

    1. Installing the pagoda Linux panel installation tutorial
    2. Graphic interface installation of various software

Practice: step by step to teach you to deploy your nodejs application

  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. Writing nginx configuration

    Let’s start 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 : start port of your project /; 
              #Attention!! It needs to be replaced here
          }
      }
    3. Upload this file to the directory / www / server / panel / Vhost / nginx / of your virtual machine
  3. Restart nginx

    1. Restart nginx to use the pagoda graphic interface. I still suggest that you learn nginx commands and learn more about nginx instead of relying on the graphical interface

Practice: step by step to teach you to deploy your nodejs application

Using ngixn common commands

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

This is the simplest step.

Practice: step by step to teach you to deploy your nodejs application
Practice: step by step to teach you to deploy your nodejs application

After configuration, try to enter your domain name in the browser, and you should be able to access your website.

summary

This is the simplest online process. If you have any difficulties, I will help you Wx: guzhan321

We rely heavily on 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 to see the installation methods and documents of the official website

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

Postscript

It's a good learning method to consult documents while practicing. Take this opportunity to open the official documents of these tools, and their documents are the best learning materials.

Get me

  • GitHub

Practice: step by step to teach you to deploy your nodejs application
Practice: step by step to teach you to deploy your nodejs application

Resource sharing:

  • Xshell free cracked 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

Differences between JavaScript mouseenter and mouseover

Triggered when the mouse moves over the elementmouseenterevent,similarmouseoverThe differences between them are as follows: mouseover: When the mouse passes through its own box, it will trigger when it passes through the sub box (becauseThere is bubbling) mouseenter: It will only trigger through its own box(It doesn’t bubble) FollowmouseenterCorrespondingly, the mouse leaves the eventmouseleavesameIt doesn’t bubble