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 https://rpm.nodesource.com/setup_6.x | 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: // 192.168.2.2: 8100/in the browser/
Access the browser directly!
Thank you for reading this article. I hope it will help you!