Node. js ~ Deployment on linux and node. jslinux

Source: Internet
Author: User

Node. js ~ Deployment on linux and node. jslinux

The following uses centOS as an example to deploy the node. js environment.

Start centos and download the node. js package.

curl --silent --location | bash -
yum -y install nodejs

2. Install the gcc Environment

yum install gcc-c++ make

Installation complete!

3. Install npm of nodejs. This is a package program tool, similar to nuget in!

sudo yum install nodejs npm

So far, even if our nodejs environment is successfully installed, we can start the path of node. js!

Add the environment variable below (shortcut, path command in windows)

// Add the shared directory export PATH =/usr/local/python/bin:/usr/local/node/bin: $ PATH // print the node version node-v

Add a test project and listen to port 8080

# Create the nodejs project directory mkdir-p/usr/local/nodejs/# create hello. js file vi/usr/local/nodejs/hello. js # Content: var http = require ("http"); http. createServer (function (request, response) {response. writeHead (200, {"Content-Type": "text/plain"}); response. write ("Hello World"); response. end ();}). listen (8080); // listener port number console. log ("Hello World is print! "); # Run node/usr/local/nodejs/hello. js in the background & # access http: // 8100/in the browser/

Access the browser directly!

Thank you for reading this article. I hope it will help you!


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.