preface

Document the steps of the nuxT build project, package it, and deploy it to the server

First, prepare the server connection part

1.1. Prepare the server connection part first

After preparing the server and obtaining the user name and password, use xshell or MAC terminal Royal TSX tool to establish a server connection. Take MAC terminal Royal TSX as an example.

Royal TSX is introduced

Royal TSX is a powerful comprehensive remote connection management software, compatible with many connection types. Royal website

The free version of the Royal TSX can connect up to 10 connections. It supports macOS, Windows, Android, iOS. After the connection is successful, you can use the command line or upload files

How do I log in to the server using Royal TSX

Using a Centos server as an example, remotely connect the server to SSH and FTPS. Download the Royal TSX plug-in and open Royal TSX

Command +, enter preferences and click Plugins to add the two plug-ins Terminal and File Transfer.

Log in to the server using SSH. “+ “is displayed in the lower left corner of the server to create a Terminal window

Enter information about the corresponding server

Set the user name and password

Login to complete

In the same Terminal operation mode, create a File Transfer and log in to the server through FTPS. The login is as follows

1.2. Install necessary software

After establishing the connection, you will need to install the Node environment. Download the latest package from the official website

Nodejs environment

There are two ways to install it under Linux. One is to download the source code and make it compiled and installed. The other is more recommended, directly download compiled binary, the official comparison of the latter.Nodejs website

After downloading the file, use the FTPS tool to drag the downloaded package with the suffix of. Tar. xz to the /usr/src directory on the server

Then open the Terminal console and enter the directory. Since it is a tar.xz compressed file, you need to decompress it with the following command:

The tar XVF - node - v14.15.1 - Linux - x64. Tar. XzCopy the code

After decompressing the binary file, it is ready to run. You only need to establish two soft connections for node and NPM to run globally:

For example, the installation location is /usr/src ln -s /usr/src/node-v14.15.1-linux-x64/bin/node /usr/local/bin/node ln -s The/usr/SRC/node - v14.15.1 - Linux - x64 / bin/NPM/usr/local/bin/NPMCopy the code

You can then enter the command node -v NPM -v to check whether the configuration is successful

Configure the use of Taobao NPM image

npm config set registry https://registry.npm.taobao.org
Copy the code

Verify success: NPM config get registry

2. Install the PM2 daemon

PM2 is a Node application process manager with load balancing function

Install pM2 globally

npm install -g pm2
Copy the code

After the installation is complete, configure the soft connection to ensure that the global command can be used to view the version using pm2 -v

Ln -s/usr/SRC/node - v14.15.1 - Linux - x64 / bin/pm2 / usr/local/bin/pm2Copy the code

Pm2 command

  • 1 Start the process or apply pm2 start bin/ WWW or pm2 start app.js
  • 2 Rename the process or application pm2 start app.js –name wb123
  • 3 Add processes/applications watch pm2 start bin/ WWW –watch
  • 4 Stop the pm2 process or application
  • 5 Stop all processes or applications
  • 6 Delete a process or apply pm2 delete WWW
  • 7 Delete all processes or apply pm2 delete all
  • 8 List all processes or applications in the PM2 list
  • Pm2 describe WWW
  • 10 Check the resource consumption of processes or applications. Pm2 monit
  • 11 View PM2 logs
  • 12 To view the logs of a process/application, run pm2 logs WWW
  • 13 Restart the process or apply the pm2 restart WWW
  • 14 Restart all processes or apply the pm2 restart all command

Next article, package nuXT and deploy it