centos7.7环境安装nodejs8、mongodb

隐身守侯 提交于 2020-10-07 04:04:27

centos7.7环境安装nodejs8


nodejs的yum安装部署
 
[root@iZbp16v1zpi82lbf50mlnxZ ~]#  curl -sL https://rpm.nodesource.com/setup_8.x | bash -


## Installing the NodeSource Node.js 8.x LTS Carbon repo...


## Inspecting system...


+ rpm -q --whatprovides redhat-release || rpm -q --whatprovides centos-release || rpm -q --whatprovides cloudlinux-release || rpm -q --whatprovides sl-release

+ uname -m


## Confirming "el7-x86_64" is supported...


+ curl -sLf -o /dev/null 'https://rpm.nodesource.com/pub_8.x/el/7/x86_64/nodesource-release-el7-1.noarch.rpm'


## Downloading release setup RPM...


+ mktemp

+ curl -sL -o '/tmp/tmp.TWX2USs2BV' 'https://rpm.nodesource.com/pub_8.x/el/7/x86_64/nodesource-release-el7-1.noarch.rpm'         (根据实际情况)


## Installing release setup RPM...


+ rpm -i --nosignature --force '/tmp/tmp.TWX2USs2BV'        (根据实际情况)



## Cleaning up...


+ rm -f '/tmp/tmp.TWX2USs2BV'          (根据实际情况)



## Checking for existing installations...


+ rpm -qa 'node|npm' | grep -v nodesource


# 默认安装最新版本 

## Run `sudo yum install -y nodejs` to install Node.js 8.x LTS Carbon and npm.

## You may also need development tools to build native addons:

     sudo yum install gcc-c++ make

## To install the Yarn package manager, run:

     curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo

     sudo yum install yarn

 

[root@iZbp16v1zpi82lbf50mlnxZ ~]# node --version

v8.17.0


[root@iZbp16v1zpi82lbf50mlnxZ ~]# npm --version

6.13.4


# 安装cnpm
[root@iZbp16v1zpi82lbf50mlnxZ ~]# npm install -g cnpm --registry=https://registry.npm.taobao.org

# 安装pm2
[root@iZbp16v1zpi82lbf50mlnxZ ~]# npm install pm2 -g



mongodb-centos7.7 yum安装mongodb

1.配置yum源

# vim /etc/yum.repos.d/mongodb-org-3.4.repo      添加如下内容

[mongodb-org-3.4]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.4/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.4.asc







2.yum安装

# yum -y install mongodb-org

3.修改mongo配置文件

# vim /etc/mongod.conf

修改dbpath

image.png

 

 4.启动mongo

配置文件启动

# /usr/bin/mongod --config=/etc/mongod.conf


5.登陆数据库,设置数据库用户和密码

# /usr/bin/mongo

> use admin

switched to db admin


> db.createUser({user:"admin",pwd:"TWX2USs2BV1wasx",roles:["root"]})

Successfully added user: { "user" : "admin", "roles" : [ "root" ] }


> db.auth("admin", "TWX2USs2BV1wasx")

1





易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!