1、下载nodejs
https://nodejs.org/en/download/
2、解压nodejs tar包到指定目录
tar -xvf /application/node-v12.13.1-linux-x64.tar.xz -C /usr/local/soft/
3、重命名文件目录名称
mv node-v12.13.1-linux-x64 node-v12.13.1
4、配置node 环境变量
vim /etc/profile
export NODE_HOME=/usr/local/soft/node-v12.13.1
export PATH=$NODE_HOME/bin:$PATH
5、刷新环境变量
source /etc/profile
6、centos 安装mongodb
下载地址:https://www.mongodb.com/download-center/community
tar -zxvf /application/mongodb-linux-x86_64-rhel70-4.0.13.tgz -C /usr/local/soft/
mv mongodb-linux-x86_64-rhel70-4.0.13 mongodb
7、配置环境变量
执行vim /etc/profile命令后按i键编辑,在文件末尾加上如下配置
export MONGO_HOME=/usr/local/mongodb
export PATH=$PATH:${MONGO_HOME}/bin
保存退出后执行:source /etc/profile 重启配置文件
8、创建data和log目录
mkdir -p /var/lib/mongo
mkdir -p /var/log/mongodb
添加 mongod用户指令: useradd -s /bin/bash mongod
修改mongod用户密码指令: passwd mongod(修改密码时需要两次输入新密码)
9、修改MongoDB相关目录的属主用户为mongod指令:
chown -R mongod:mongod /usr/local/mongodb
chown -R mongod:mongod /var/lib/mongo
chown -R mongod:mongod /var/log/mongodb
10.启动mongo
1)执行 cd usr/local/mongodb/bin 命令
2)执行 ./mongod -f /usr/local/mongodb/conf/mongodb.conf 命令
3)新开一个客户端窗口,仍然使用mongod用户的连接,执行命令 ./mongo
./mongod --config /usr/local/soft/mongodb/conf/mongodb.conf & 后台运行
10、安装及部署yapi
-
npm install -g yapi-cli --registry https://registry.npm.taobao.org
-
/usr/local/soft/node-v12.13.1/bin/yapi server &
-
-
gyp WARN EACCES current user does not have permission to access the dev dir "/root/.cache/node-gyp/12.13.1"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/soft/mongodb/bin/my-yapi/vendors/node_modules/dtrace-provider/.node-gyp"gyp WARN install got an error, rolling back install
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/soft/mongodb/bin/my-yapi/vendors/node_modules/dtrace-provider/.node-gyp'
gyp ERR! System Linux 3.10.0-1062.1.2.el7.x86_64
gyp ERR! command "/usr/local/soft/node-v12.13.1/bin/node" "/usr/local/soft/node-v12.13.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/soft/mongodb/bin/my-yapi/vendors/node_modules/dtrace-provider
gyp ERR! node -v v12.13.1
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok -
部署失败,因为目录缺少root权限
-
chmod -R 777 /var/log/mongodb/
-
chmod -R 777 /var/lib/mongo/
-
chown -R 777 /usr/local/soft/
-
chown -R root /usr/local/soft/node-v12.13.1/
-
chgrp -R root /usr/local/soft/node-v12.13.1/
11、部署成功