How to install node. js and express in CentOS Linux, centosnode. js
Preface
Recently, we need to install and use node. js and express because of work requirements. However, I have found many steps and various problems on the Internet, so I 'd like to summarize them myself.
1. Download
wget --no-check-certificate https://nodejs.org/dist/v6.10.1/node-v6.10.1-linux-x64.tar.xz
2. Decompress
tar xvf node-v6.10.1-linux-x64.tar.xz
Node and npm already exist in the bin folder and are set to global.
sudo ln -s /data/node-v6.10.1-linux-x64/bin/node /usr/local/bin/node sudo ln -s /data/node-v6.10.1-linux-x64/bin/npm /usr/local/bin/npm
3. Install express
npm install express -gd npm install -g express-generator
Set express to global:sudo ln -s /data/node-v6.10.1-linux-x64/bin/express/usr/local/bin/express
4. Successful
express --version
5. npm start in the project
Enter 127.0.0.1: 3000 in the browser
Welcome to express!
If not, check the Firewall:
Modify/etc/sysconfig/iptables
File to add the following content:
In-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
Add
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 3000 -j ACCEPT
Open the firewall to port 3000.
6. Successful again!
Summary
The above is all the content of this article. I hope the content of this article will help you in your study or work. If you have any questions, please leave a message, thank you for your support.