Configure the node. js environment in Centos7

Source: Internet
Author: User
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:

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
[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

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, " ");
Console. log ('server running
Http: // 8421 /');

SaveTest. jsAnd enterNode test. js, Open in a browserHttp: // 8421/, You will find the outputHello Node. js

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.