#检查是否已经安装
rpm -qa | grep python

#查版本
python

#最好是重新安装 Python推荐版本( >= v2.5.0 & < 3.0.0 ),否则影响nodejs运行

#进入安装目录
cd /usr/local/

#删除原有安装
rm -rf node
rm -rf node-v0.10.29-linux-x64

#解压压缩包
tar -zxv -f node-v0.10.29-linux-x64.tar.gz

#修改目录
mv node-v0.10.29-linux-x64 node

#添加环境变量并使之生效,内容如下:
export PATH=/usr/local/python/bin:/usr/local/node/bin:$PATH

#测试命令
node -v

#--------------------测试----------------------------
#创建nodejs项目目录
mkdir -p /usr/local/nodejs/

#创建hello.js文件
vi /usr/local/nodejs/hello.js

#内容如下:
var http = require("http");
http.createServer(function(request, response) {
	response.writeHead(200, {
		"Content-Type" : "text/plain" // 输出类型
	});
	response.write("Hello World");// 页面输出
	response.end();
}).listen(8100); // 监听端口号
console.log("nodejs start listen 8102 port!");


#后台运行
node /usr/local/nodejs/hello.js &

#浏览器访问
http://192.168.2.2:8100/

相关文章:

  • 2021-11-20
  • 2021-08-16
  • 2021-05-08
  • 2021-11-01
  • 2021-12-11
  • 2021-09-13
  • 2021-11-15
  • 2021-06-07
猜你喜欢
  • 2022-01-07
  • 2021-10-30
  • 2021-06-24
  • 2021-10-16
  • 2021-12-23
  • 2021-09-25
  • 2021-12-14
  • 2021-09-04
相关资源
相似解决方案