标签:figure 64位 lin end centos7.3 UI 内容 amp ejs
一.安装wget https://nodejs.org/dist/v8.9.4/node-v8.9.4.tar.gz
cd node-v8.9.4/
./configure --prefix=/usr/local/nodejs
make
make install
二.nodejs设置环境变量
vim /etc/profile.d/nodejs.sh
#输入以下内容
export NODEJS_HOME=/usr/local/nodejs
PATH=$PATH:$NODEJS_HOME/bin
刷新环境变量
source /etc/profile.d/nodejs.sh
三.测试
运行项目web.js
var http = require(‘http‘);
http.createServer(function (req, res) {
res.writeHead(200, {‘Content-Type‘: ‘text/plain‘});
res.end(‘Hello World\n‘);
}).listen(1337, ‘127.0.0.1‘);
console.log(‘Server running at http://127.0.0.1:1337/‘);
To run the server, put the code into a file example.js and execute it with the node program from the command line:
% node example.js
Server running at http://127.0.0.1:1337/
Here is an example of a simple TCP server which listens on port 1337 and echoes whatever you send it:
var net = require(‘net‘);
var server = net.createServer(function (socket) {
socket.write(‘Echo server\r\n‘);
socket.pipe(socket);
});
server.listen(1337, ‘127.0.0.1‘);
标签:figure 64位 lin end centos7.3 UI 内容 amp ejs
原文地址:http://blog.51cto.com/shenshen/2061107