centos 6.x x86_64装nodejs模块ws
2015-11-04 00:00
706 查看
摘要: 为了在nodejs下用下websocket,需要装个ws模块,于是就去装了。我知道还有其他模块实现,反正我就选了这个去实验。
为了在nodejs下用下websocket,需要装个ws模块,于是就去装了。我知道还有其他模块实现,反正我就选了这个去实验。
关于centos装nodejs请参考这文章:http://stackoverflow.com/questions/20028996/how-to-install-node-binary-distribution-files-on-linux ,用的是Amin Meyghani的回复方法。
一开始当然是不成功的,发现有个关键提示:
搜索了下发现C++11需要gcc 4.7以上,系统默认的是4.4.7.不合要求。
下面正确装ws模块的节奏:
step 0:
升级 gcc 到4.7以上,参考:http://superuser.com/questions/381160/how-to-install-gcc-4-7-x-4-8-x-on-centos
不过我装的是devtools-2,一个不新不旧的版本。
2.0的安装好位置在:
注意不是1.1的:
相应export环境变量也改成:
gcc升级完成。这时运行gcc -v仍旧显示 4.4.7,应该是path没改,但这样也不影响node-gyp编译,就没理会它。
step 1:
装ws模块
ws模块编译通过,安装成功。
Done,可以愉快的使用ws了
为了在nodejs下用下websocket,需要装个ws模块,于是就去装了。我知道还有其他模块实现,反正我就选了这个去实验。
关于centos装nodejs请参考这文章:http://stackoverflow.com/questions/20028996/how-to-install-node-binary-distribution-files-on-linux ,用的是Amin Meyghani的回复方法。
一开始当然是不成功的,发现有个关键提示:
../node_modules/nan/nan.h:41:3: error: #error This version of node/NAN/v8 requires a C++11 compiler
搜索了下发现C++11需要gcc 4.7以上,系统默认的是4.4.7.不合要求。
下面正确装ws模块的节奏:
step 0:
升级 gcc 到4.7以上,参考:http://superuser.com/questions/381160/how-to-install-gcc-4-7-x-4-8-x-on-centos
不过我装的是devtools-2,一个不新不旧的版本。
cd /etc/yum.repos.d wget http://people.centos.org/tru/devtools-2/devtools-2.repo yum --enablerepo=testing-2-devtools-6 install devtoolset-2-gcc devtoolset-2-gcc-c++
2.0的安装好位置在:
/opt/rh/devtoolset-2/root/usr/bin/
注意不是1.1的:
/opt/centos/devtoolset-1.1/root/usr/bin/
相应export环境变量也改成:
export CC=/opt/rh/devtoolset-2/root/usr/bin/gcc export CPP=/opt/rh/devtoolset-2/root/usr/bin/cpp export CXX=/opt/rh/devtoolset-2/root/usr/bin/c++
gcc升级完成。这时运行gcc -v仍旧显示 4.4.7,应该是path没改,但这样也不影响node-gyp编译,就没理会它。
step 1:
装ws模块
npm install -g ws
ws模块编译通过,安装成功。
Done,可以愉快的使用ws了
相关文章推荐
- Centos6 编译安装Python
- 2015-2016网页设计趋势分析 Web Design of Trends
- 硬盘安装CentOS 6.2以及添加GRUB启动菜单
- CentOS 6.2实战部署Nginx+MySQL+PHP
- CentOS 7系统配置上的变化解析
- CentOS下DB2数据库安装过程详解
- CentOS 6.3下编译安装Ruby 2.0笔记
- 使用ruby部署工具mina快速部署nodejs应用教程
- Google官方支持的NodeJS访问API,提供后台登录授权
- 浅谈Nodejs观察者模式
- nodejs教程之环境安装及运行
- nodejs中的fiber(纤程)库详解
- 基于NodeJS的前后端分离的思考与实践(五)多终端适配
- 基于NodeJS的前后端分离的思考与实践(二)模版探索
- 我的NodeJs学习小结(一)
- nodejs中实现sleep功能实例
- Nodejs异步回调的优雅处理方法
- Windows系统下使用Sublime搭建nodejs环境