This is the 24th day of my participation in the August Text Challenge.More challenges in August

1. Install Node.js on CentOS

User: root

1.1 Download and upload node. js

Viewing system bits

uname -a
Copy the code

The view here is 64-bit.

Download it from Node.js Chinese website

Example Change the name of the downloaded package to nodejs.tar.xz

Switch to the directory where you want to install Node and upload nodejs.tar.xz

cd usr/software 
Copy the code
rz -y
Copy the code

This step can also be done by downloading Node.js using wget

wget https://npm.taobao.org/mirrors/node/v11.7.0/node-v11.7.0-linux-x64.tar.xz
Copy the code

ps:

Linux wget is a tool for downloading files from the command line. This is an essential tool for Linux users, especially network administrators, who often need to download some software or restore backup from a remote server to a local server. If we use a virtual host, we can only download this transaction from the remote server to our computer disk, and then upload it to the server using FTP tool. It’s a waste of time and energy. It can’t be helped. With Linux VPS, it can be downloaded directly to the server without having to upload. The wGET tool is small but functional. It supports breakpoint download function, FTP and HTTP download mode, supports proxy server and easy to set up.

Wget installed

yum -y install wget
Copy the code

1.2 Decompress nodejs.tar.xz and rename it

tar -xvf nodejs.tar.xz
Copy the code

mv node-v14.15.4-linux-x64 nodejs
Copy the code

1.3 Establishing a soft Connection Becomes global

We can see that the bin directory points to user/bin:

In this case, the node -v command cannot display the node version number, because the node command cannot be used globally. You need to set up a soft link to make the node version global. In Windows, you need to configure global variables.

The bin directory of the decompressed file contains commands such as node and NPM. You can use the ln command to set the soft connection:

ln -s /usr/software/nodejs/bin/node /usr/bin/
ln -s /usr/software/nodejs/bin/npm /usr/bin/
Copy the code

/user/bin/node and /user/bin/ NPM.

1.4 Verifying the installation

node -v
npm -v
Copy the code

See display version information is ok

1.5 Installing Other Tools

1.5.1 Installing CNPM Taobao Image

npm install -g cnpm --registry=https://registry.npm.taobao.org
Copy the code

Creating soft Links

ln -s /usr/software/nodejs/bin/cnpm /usr/bin/
Copy the code

1.5.2 to install pm2

PM2 is a node process management tool. It can be used to simplify many node application management tasks, such as performance monitoring, automatic restart, load balancing, and so on.

cnpm install -g pm2
Copy the code

Creating soft Links

ln -s /usr/software/nodejs/bin/pm2 /usr/bin/
Copy the code