Node installation and deployment
Go to the official website to download the latest version, which is the source code and the compiled file. The following is the official website download address:/en/download/current/Download the corresponding version of win linux mac in different versions
Take Linux Windows as an example
Installation under Linux: (Method 1)
1.1 Decompress the downloaded compressed package file
1.2 Decompression command: tar -zxvf (name of the compressed package.)
1.3 After decompression is completed, you can see node and npm files in the bin file. Execute in the current directory./node can execute node client
1.4 Setting up the client: two commands node and npm
(kun/mysofltware/node-v0.10.28-linux-x64/bin/node) The node file storage location depends on its own storage location
ln -s /home/kun/mysofltware/node-v0.10.28-linux-x64/bin/node /usr/local/bin/node ln -s /home/kun/mysofltware/node-v0.10.28-linux-x64/bin/npm /usr/local/bin/npm
1.5 Execute pwd in the node directory to get the directory where the node is located. Add this directory to the PATH environment variable
1.6 Execute su Enter the password and switch to the root user Execute the command: vi /etc/profile
1.7 In vi environment, click i to enter the insertion state, and add the following content to the previous line of export PATH (the content in the environment variable is divided by colon)
PATH=$PATH:/home/kun/mysofltware/node-v0.10.26-linux-x64/bin
After editing is completed, press Esc key and enter :wq Press Enter to save and exit.
1.8 Exit vi, execute source /etc/profile to make the variable take effect
1.9 Then execute echo $PATH to see if the output contains the content you added by yourself
Installation under Linux: (Method 2)
2.1 Decompress the downloaded source code source code
2.2 Use this to execute the following command
cd node-v0.10 ./configure Make Make install cp /usr/local/bin/node /usr/sbin/
Installation under Linux: (Method 3) [Not recommended]
apt-get method
Sudo apt-get install Sudo apt-get install npm
Installing under Windows is relatively simple to download the next step (not elaborate on)
Install the redis database
3.1 Download the source code, decompress and compile the source code.
wget /releases/redis-2.8. tar xzf redis-2.8. cd redis-2.8.3 make
3.2 After compilation is completed, in the Src directory, there are four executable files, redis-server, redis-benchmark, redis-cli and. Then copy it to a directory.
mkdir /usr/redis cp redis-server /usr/redis cp redis-benchmark /usr/redis cp redis-cli /usr/redis cp /usr/redis cd /usr/redis
3.3 Start Redis Service
redis-server
3.4 Then use the client to test whether the startup is successful.
redis-cli redis> set foo bar OK redis> get foo"bar"
Code upload
4.1 Packaging: Command (node_modules .idea .git These files are not packaged to reduce the size of the compressed package)
$ tar cvzf ./ --exclude=node_modules --exclude=.idea --exclude=.git --exclude=
4.2 Upload: Command
$ scp ./ Hostname@IP address: path to folder
4.3 Execute the command to log in to the remote host ssh host name @IP address and then prompt for password
4.4 cd ls Enter the directory where the compressed package is uploaded and execute tar -zxvf to decompress the file
4.5 npm Install environment dependency Execute the command npm install
Query DNS port before deployment under root permissions
5.1 Command: $ netstart -ntupl
Close the firewall root permissions
6.1 firewall-cmd --zone=public --add-port=9010/tcp --permanent
6.2 firewall-cmd --reload
Note: The 9010 is the port number that the project needs to open
Install pm2
7.1 su get root permission to download pm2
Command: $ npm install pm2 -g
$ pm2 start www start process
8.2 Install the power-on start-up. Run the following command under root permissions
$ pm2 startup $ pm2 save
9.3 Some commonly used pm2 commands
$ pm2 list Check the startup status
$ pm2 restart Restart the project
$ pm2 stop Close
Other commands can be referenced/package/pm2
The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.