How to deploy Node.js environment on linux
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!