MongoDB安装及配置
创建/etc/yum.repos.d/mongodb-org-3.2.repo
文件,内容如下:
1 2 3 4 5 6
| [mongodb-org-3.2] name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.2/x86_64/ gpgcheck=1 enabled=1 gpgkey=https://www.mongodb.org/static/pgp/server-3.2.asc
|
- yum -y install mongodb-org
配置MongoDB
- 添加数据库和用户
当MongoDB数据库服务位于启动状态时,执行如下命令
1 2 3
| $ mongo $ use nodebb $ db.createUser({user: "nodebb", pwd: "<Enter in a secure password>", roles: [ "readWrite" ]})
|
1 2 3
| #注释掉security选项,并添加认证字段 security: authorization: enabled
|
重新启动MongoDBsystemctl start mongod
安装node.js
通过nvm管理器来安装最新版的nodejs
1 2 3 4 5 6 7 8
| curl https://raw.githubusercontent.com/creationix/nvm/v0.13.1/install.sh | bash source ~/.bash_profile NVM_NODEJS_ORG_MIRROR=https://npm.taobao.org/mirrors/node nvm list-remote NVM_NODEJS_ORG_MIRROR=https://npm.taobao.org/mirrors/node nvm install v6.3.0
|
安装nodebb依赖
1 2 3 4 5
| yum -y install epel-release yum -y groupinstall "Development Tools" yum -y install git ImageMagick npm
|
安装nodebb
1 2 3 4
| $ cd /path/to/nodebb/install/location # 下载nodebb源码 -b 指定分支 $ git clone -b v1.0.3 https://github.com/NodeBB/NodeBB nodebb
|
指定分支时,可以根据最新版本进行替换
1 2 3 4 5
| $ cd nodebb $ npm --registry=https://registry.npm.taobao.org install $ ./nodebb setup
|
初始化之后,会生成config.json,可以对nodebb全局配置
bind_address
默认是0.0.0.0
,由于nodebb和nginx位于一台服务器,为了安全起见,修改为127.0.0.1
由于nginx和node.js位于一台服务器,使用如下配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| $ yum -y install nginx server { listen 80; server_name forum.example.org; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; proxy_pass http://127.0.0.1:4567/; proxy_redirect off; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } }
|
1 2 3
| $ npm $ forever start app.js
|