Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to deploy Node.js environment on linux

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the knowledge of "how to deploy the Node.js environment on linux". In the operation of practical cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

As soon as you open centos, start downloading the node.js package

Curl-silent-location https://rpm.nodesource.com/setup_6.x | bash-yum-y install nodejs

Second, install gcc environment

Yum install gcc-c++ make

Installation complete!

Install npm of nodejs, which is a package tool, similar to nuget in vs!

Sudo yum install nodejs npm

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

Add environment variables (shortcuts, path directives in windows)

/ / add a shared directory export path=/usr/local/python/bin:/usr/local/node/bin:$path// print node version node-v

Add a test project and listen on port 8080

# create nodejs project directory mkdir-p / usr/local/nodejs/# create hello.js file vi / usr/local/nodejs/hello.js

The contents are as follows:

Var http = require ("http"); http.createserver (function (request, response) {response.writehead (200,{ "content-type": "text/plain"}); response.write ("hello world"); response.end ();}) .listen (8080); / / listen port number console.log ("hello world is print!") # run node / usr/local/nodejs/hello.js in the background & # browser to access http://192.168.2.2:8100/

Just visit the browser directly!

That's all for "how the Node.js environment is deployed on linux". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report