Linux program installation -- offline installation of node and pm2

This operation is offline installation, because the assigned server does not have access to the external network.

1. Download node's official address: https://nodejs.org/en/ Sometimes the official website can't be opened (don't know why, hehe...), I downloaded "node-v6.10.0-linux-x64.tar. xz" version and upload it to the server, because the final format of the version is.

2. Unzip the node

xz -d node-v6.10.0-linux-x64.tar.xz

 3. Execute the above command to decompress the node-v6.10.0-linux-x64.tar file, we have to decompress it again

tar -zxvf node-v6.10.0-linux-x64.tar

4. Enter the decompressed node-v6.10.0-linux-x64/bin/ directory and check the version of node

node -v

 5. Configure the environment

    (1)Edit

# vim /etc/profile
Need root privileges, no root privileges
$ sudo vim /etc/profile

    (2) Add the following configuration

export NODE_HOME=/home/shuang/software/node-v6.10.0-linux-x64
export PATH=$NODE_HOME/bin:$PATH

    (3) Revalidate the configuration

# source /etc/profile
I have also seen the following commands on the Internet, and the configuration takes effect, but I have not tried it without success, I don’t know why
# . /etc/profile

    (4) Verify that the node configuration is successful

node -v

Execute the above command, if you can see the version information, it proves that the configuration is successful

 6. Install pm2

    I know that the way to install pm2 is "npm install -g pm2". Unfortunately, this is an online installation. I saw on the Internet that you can download pm2 separately and then configure the environment. The premise is that you have to have the corresponding installation package. What if you don't have a package yourself? My solution The method is to install it once under a linux system that can access the external network (how important it is to have a virtual machine -_- ), then find the installation package, package it and put it on the server to be installed. This is generally the case, Proceed as follows:

   (1) First install and configure node according to the above steps

   (2) Execute the command to install, the following command and figure:

npm install -g pm2

     After the installation is successful, the picture is as follows:

   (3) Package pm2 to prepare for the server to be installed

       In the above figure, you can see the path of our pm2 installation. After entering "node-v6.10.0-linux-x64/lib/node_modules", you can see the pm2 file directory and execute the packaging command

tar -zcvf pm2.tar.gz pm2

   (4) Copy the packaged pm2 program to the server to be installed, and where to copy it, I think you should know it, that is, find the directory where you installed node before, that is, the directory where you operated node above, Also put it in the "node-v6.10.0-linux-x64/lib/node_modules" directory, and then extract it.

   (5) Configure the pm2 environment

1. Edit the profile file
# vim /etc/profile
Need root privileges, no root privileges
$ sudo vim /etc/profile

2. Add the following configuration
export PM2_HOME=/home/app/node-v6.10.0-linux-x64/lib/node_modules/pm2
export PATH=$PM2_HOME/bin:$PATH

3. Execute the following command to take effect
# source /etc/profile
The # sign in front indicates that root privileges are required, if not
sudo source /etc/profile

    (6) Verify that pm2 is successfully installed

pm2 list

 

See literature:

 

http://blog.csdn.net/chenxiao_zhl/article/details/48180193

 

node and pm2 add-ons

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326678555&siteId=291194637