1. software environment: Centos7, VMware10.0, NodeJSv0.10.242, and installation process 1 require administrator and root permissions. you can run the following commands. & Nbs
1. software environment:
Centos7, VMware 10.0, NodeJS v0.10.24
2. installation process
1. administrator and root permissions are required during installation. you can run the following command.
[Sharing @ localhost ~] $ Su root
After you press enter, the following message is displayed:
Password:
Enter the password you set. it is not displayed on the terminal during the input process, but it has already been entered. The input is as follows:
[Root @ localhost sharing] #
2. first confirm that nodejs compilation and dependency software are available. if not, run the following command to install nodejs.
[Root @ localhost sharing] # yum-y install gcc-c ++ openssl-devel
3. download and decompress the Node. js source code package.
[Root @ localhost sharing] # wget http://nodejs.org/dist/v0.10.24/node-v0.10.24.tar.gz
[Root @ localhost sharing] # tar zxvf node-v0.10.24.tar.gz
[Root @ localhost sharing] # cd node-v0.10.24
4. configure, compile, and install.
[Root @ localhost node-v0.10.24] #./configure -- prefix =/usr/local/node
[Root @ localhost node-v0.10.24] # make & make install
5. configure the Node environment
[Root @ localhost node-v0.10.24] # vim/etc/profile too many
Use vim for the first time... After vim enters the profile, we will see the content in the profile file, press the keyboard I to enter the editing mode, and then write the following content at the end of the text.
Export NODE_HOME =/usr/local/node
Export PATH = $ NODE_HOME/bin: $ PATH
Export NODE_PATH = $ NODE_HOME/lib/node_modules: $ PATH
After the input, press Esc to exit the editing mode, and then press: wq to exit and save.
Then enter the following command to take effect.
[Root @ localhost node-v0.10.24] # source/etc/profile
6. test whether it is successful
[Root @ localhost node-v0.10.24] # node-v
V0.10.24
The NodeJS version number indicates that the installation is successful.
7 test example
Enter the following code to create a new text:
Var http = require ('http ');
Http. createServer (function (req, res ){
Res. writeHead (200, {'content-type': 'Text/plain '});
Res. end ('Hello Node. js \ n ');
}). Listen (8421, "127.0.0.1 ");
Console. log ('server runningHttp: // 127.0.0.1: 8421 /');
SaveTest. jsAnd enterNode test. js, Open in a browserHttp: // 127.0.0.1: 8421/, You will find the outputHello Node. js