专业的编程技术博客社区

网站首页 > 博客文章 正文

在centOS 6下部署node以及安装pm2

baijin 2024-08-30 11:40:46 博客文章 2 ℃ 0 评论

报错问题

我在 CentOS 6 上编译 node 源代码的时候,有以下报错:

[root@node ~]# cd node-v4.4.7

[root@node node-v4.4.7]# ./configure

WARNING: C++ compiler too old, need g++ 4.8 or clang++ 3.4 (CXX=g++)

creating ./icu_config.gypi

{ 'target_defaults': { 'cflags': [],

'default_configuration': 'Release',

'defines': [],

'include_dirs': [],

'libraries': []},

'variables': { 'asan': 0,

'gas_version': '2.20',

'host_arch': 'x64',

'icu_small': 'false',

'node_byteorder': 'little',

'node_install_npm': 'true',

'node_prefix': '/usr/local',

'node_release_urlbase': '',

'node_shared_http_parser': 'false',

'node_shared_libuv': 'false',

'node_shared_openssl': 'false',

'node_shared_zlib': 'false',

'node_tag': '',

'node_use_dtrace': 'false',

'node_use_etw': 'false',

'node_use_lttng': 'false',

'node_use_openssl': 'true',

'node_use_perfctr': 'false',

'openssl_fips': '',

'openssl_no_asm': 0,

'target_arch': 'x64',

'uv_parent_path': '/deps/uv/',

'uv_use_dtrace': 'false',

'v8_enable_gdbjit': 0,

'v8_enable_i18n_support': 0,

'v8_no_strict_aliasing': 1,

'v8_optimized_debug': 0,

'v8_random_seed': 0,

'v8_use_snapshot': 'true',

'want_separate_host_toolset': 0}}

creating ./config.gypi

creating ./config.mk

WARNING: warnings were emitted in the configure phase

这是由于 CentOS 6 中编译 node4+ 需要高版本号的 C++ 编译器。

事实上,我推崇大家直接下载已编译好的 node 版本,可以避开很多坑。

解决办法

安装 Node.js v4 最新版本执行下面的命令:

[root@node node-v4.4.7]# curl --silent --location https://rpm.nodesource.com/setup_4.x | bash -

安装 Node.js v6 最新版本执行下面的命令:

[root@node node-v4.4.7]# curl --silent --location https://rpm.nodesource.com/setup_6.x | bash -

接着执行:

[root@node node-v4.4.7]# yum -y install nodejs

查看版本

[root@node node-v4.4.7]# node -v

v4.4.7

参考官网说明:https://nodejs.org/

题外话安装pm2

安装:

[root@node ui.orzhtml.inner]# npm install -g pm2

启动程序:

[root@node ui.orzhtml.inner]# pm2 start app.js

[PM2] Starting app.js in fork_mode (1 instance)

[PM2] Done.

┌──────────┬────┬──────┬──────┬────────┬─────────┬────────┬─────────────┬──────────┐

│ App name │ id │ mode │ pid │ status │ restart │ uptime │ memory │ watching │

├──────────┼────┼──────┼──────┼────────┼─────────┼────────┼─────────────┼──────────┤

│ app │ 0 │ fork │ 5163 │ online │ 0 │ 0s │ 12.863 MB │ disabled │

└──────────┴────┴──────┴──────┴────────┴─────────┴────────┴─────────────┴──────────┘

Use `pm2 show <id|name>` to get more details about an app

其他命令:

//启动程序:

pm2 start <app_name|id|all>

//列举进程:

pm2 list

//退出程序:

pm2 stop <app_name|id|all>

//重起应用:

pm2 restart

//程序信息:

pm2 describe id|all

//监控:

pm2 monit

//实时集中log处理:

pm2 logs

pm2命令


本文内容均属个人原创作品,转载此文章须附上出处及原文链接。

关注 web翎云阁,定时推送,互动精彩多,若你有更好的见解,欢迎留言探讨!

Tags:

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表