linux安装MongoDB

2-2安装依赖库:

yum -y install pcre*

yum -y install openssl*

2-3安装node

yum install git

2-4安装MongoDB:

下载:curl -O https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-4.2.1.tgz

解压: tar zxvf mongodb-linux-x86_64-4.2.1tgz

移动: mv mongodb-linux-x86_64-4.2.1/ /usr/local/mongodb

创建数据文件夹 日志文件和mongo配置文件

mkdir -p /usr/local/mongodb/data/db

touch /usr/local/mongodb/mongo.log

touch /usr/local/mongodb/mongodb.conf

在配置文件中加入如下代码:

dbpath=/usr/local/mongodb/data/db

logpath=/usr/local/mongodb/log/mongod.log

logappend = true

port = 27017

fork = true

muth = true

切换到mongodb的bin目录下

启动:./mongod --dbpath /usr/local/mongodb/data/db

mongod -dbpath=/usr/local/mongodb/data --bind_ip 0.0.0.0

指定所有用户都可以连接,只是暂时的,后期项目部署上去后,肯定是要关闭的

2-5安装nginx静态资源服务器

下载 wget (类似于迅雷,用来下载文件的)

yum install wget

下载 nginx

wget http://nginx.org/download/nginx-1.21.1.tar.gz

解压

tar zxvf nginx-1.21.1.tar.gz

进入解压目录,编译

./configure

安装

make install

安装完成后会在同级目录生成一个nginx的目录,这个才是服务器目录

2-6上传静态资源

打包前台代码

npm run build

打包后台代码

npm run build:prod

将打包好的前台代码放到 nginx 的 html 文件夹下,将打包好的后台代码放到 nginx/html/admin 目录下

修改nginx的配置文件,添加代理设置:

location / {

root html;

index index.html index.htm;

try_files uri uri/ /index.html;

}

location /api {

proxy_pass http://127.0.0.1:7001;

}

location /res {

proxy_pass http://127.0.0.1:7001;

}

location /static {

proxy_pass http://127.0.0.1:7001;

}

修改配置文件后需要重启一下服务器

nginx 常用命令

nginx: 启动

nginx -v :查看版本

nginx -s stop :停止

nginx -s reload :重启

2-7进程守护

在linux中,可以输入

nohup command &

来把进程挂起,这样即使退出了远程连接,也能够继续保持进程

使用示例:

nohup npm start &

挂起进程后,使用 exit 命令退出远程连接

2-8安装node和mongodb

相关推荐
用户03284722207010 小时前
如何搭建本地yum源(上)
运维
A小辣椒2 天前
TShark:Wireshark CLI 功能
linux
A小辣椒2 天前
TShark:基础知识
linux
AlfredZhao2 天前
OCI 明明分配了 200G 系统盘,为什么 df 只看到 30G?
linux·oci
AlfredZhao2 天前
vi 删除指定范围的行,不用再反复按 dd
linux·vi
用户9718356334663 天前
银河麒麟 KY10 申威(SW64) 安装 nginx-1.16.1-2.p01.ky10.sw_64.rpm 详细步骤
linux
猪脚踏浪3 天前
linux 拷贝文件或目录到指定的位置
linux
大树883 天前
金刚石散热越强,管路越先见顶
大数据·运维·服务器·人工智能·ai
摇滚侠3 天前
Linux CentOS7 rpm 安装 MySQL 5.7
linux·运维·mysql
霸道流氓气质3 天前
领域驱动设计(DDD)在 Spring Boot 微服务中的实践指南
运维·spring boot·微服务