首页

  • 首页
  • 友链
  • 标签
  • 关于

‘node+vue+mongodb部署项目

白羊座的梦 发布于 2019-11-02

node+vue+mongodb部署项目

安装node和mongodb数据库

放到全局变量

安装mongo数据库的相关详细操作

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
使用wget下载

cd /usr/local
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel62-3.2.7.tgz
tar -xvf mongodb-linux-x86_64-rhel62-3.2.7.tgz
mv mongodb-linux-x86_64-rhel62-3.2.7 mongodb
配置环境变量
修改/etc/profile, 添加如下内容

export MONGODB_HOME=/usr/local/mongodb
export PATH=$MONGODB_HOME/bin:$PATH
执行命令:
vim /etc/profile
source /etc/profile


启动

创建数据库目录

MongoDB需要自建数据库文件夹.
mkdir -p /data/mongodb
mkdir -p /data/mongodb/log
touch /data/mongodb/log/mongodb.log
添加配置文件
新建mongodb.conf配置文件, 通过这个配置文件进行启动.
vim /etc/mongodb.conf
配置文件内容:
dbpath=/data/mongodb
logpath=/data/mongodb/log/mongodb.log
logappend=true
port=27017
fork=true
##auth = true # 先关闭, 创建好用户在启动

通过配置文件启动
mongod -f /etc/mongodb.conf
about to fork child process, waiting until server is ready for connections.
forked process: 2814
child process started successfully, parent exiting
出现successfully表示启动成功了.

进入 MongoDB后台管理 Shell
cd /usr/local/mongodb/bin
./mongo
创建数据库

use test
switched to db test
创建成功.

关闭数据库

1
2
3
4
5
ps aux|grep mongo //查看有几个数据库的端口在运行
cd /usr/local/mongodb/bin/mongod //来到这个mongo数据库的mongod文件
./mongo //进入数据库(现在进入到数据库中了)
use admin
db.shutdownServer()(关闭数据库);

自定义数据库

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
MongoDB需要自建数据库文件夹.
mkdir -p /data/mongodb
mkdir -p /data/mongodb/log
touch /data/mongodb/log/mongodb.log
添加配置文件
新建mongodb.conf配置文件, 通过这个配置文件进行启动.
vim /etc/mongodb.conf
配置文件内容: 只要地址对,名称自取
dbpath=/data/mongodb
logpath=/data/mongodb/log/mongodb.log
logappend=true
port=27017
fork=true
##auth = true # 先关闭, 创建好用户在启动
通过配置文件启动
mongod -f 自定义的配置文件启动数据库.conf;

LINUX安装nginx详细步骤

1.安装依赖包

1
2
//一键安装上面四个依赖
yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel

2.下载并解压安装包

1
2
3
4
5
6
7
//创建一个文件夹
cd /usr/local
mkdir nginx
cd nginx
//下载tar包
wget http://nginx.org/download/nginx-1.13.7.tar.gz
tar -xvf nginx-1.13.7.tar.g

3.安装nginx

1
2
3
4
5
6
7
8
9

//进入nginx目录
cd /usr/local/nginx
//执行命令
./configure
//执行make命令
make
//执行make install命令
make install

4.配置nginx.conf

1
2
3
4
5
6
7
# 打开配置文件
vi /usr/local/nginx/conf/nginx.conf
4. 进入nginx文件夹修改 cd /etc/nginx , vim nginx.conf

在http模块增加server, 其中location /api/ 是代理用的。
如果用/api代理,前台的/api没有去掉那么,后台也要加上/api否则会报错404错误;
这里一定要注意

将端口号改成8089,因为可能apeache占用80端口,apeache端口尽量不要修改,我们选择修改nginx端口。
localhost修改为你服务器ip地址。

5.nginx的相关操作

1
2
3
4
5
6
7
8
9
10
11
12
1.启动
启动代码格式:nginx安装目录地址 -c nginx配置文件地址
列如/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
2. nginx的停止有三种方式:
1、查看进程号
ps -ef|grep nginx
2、杀死进程
kill -QUIT 2072
3.杀死进程
kill -TERM 2132
4.强制停止
pkill -9 nginx

怎样启动和关闭NGINX服务器

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
启动: 直接使用命令: nginx

启动

service
nginx start

重启

nginx -s reload


关闭1: 快速停止

nginx -s stop


关闭2: 完整有序停止

nginx -s quit


重启: 如下

nginx -s reload

使用进程守卫持续登录node服务;

1
2
3
4
5
6
7
8
9
10
下载pm2
npm i pm2 -g
是否安装成功
pm2 -v
运行项目
pm2 start node项目名.js
查看运行项目
pm2 list
停止项目
pm2 stop node项目名.js

这篇文章讲的比较详细

这篇文章比较详细

这篇文章讲的比较详细

  • #项目过程
Newer
react路由
Older
node中cookie和session配合使用

© 2020 白羊座的梦

Powered by Hexo Theme - flex-block