ubuntu 安装nodebb

介绍

NodeBB是Design Create Play开发的一款使用Node.js构建的论坛系统,使用redis或mongoDB数据库,采用web socket技术实现。支持响应式布局,兼容IE8,将论坛的体验带向一个新的高度。(国外的论坛系统都相当纯粹,并不会像Discuz、phpwind那样提供各种建站所需模块)

原文链接:nodebb官网 https://docs.nodebb.org/installing/os/ubuntu/

Installing on Ubuntu

Ubuntu 16.04 安装向导 并且使用 MongoDB作为 NodeBB的数据库.
系统要求
内存: 安装NodeBB’s 依赖可能至少需要 512 M . 如果您的Linux系统内存不足,建议启用交换分区来补偿。

安装nodejs

$ curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
$ sudo apt-get install -y nodejs

检查安装结果

$ node -v
v8.11.3
$ npm -v
5.8.0

安装MongoDB

$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5
$ echo "deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list
$ sudo apt-get update
$ sudo apt-get install -y mongodb-org

检查安装结果

$ mongod --version
db version v3.6

启动mongodb并查看启动状态

$ sudo systemctl start mongod
$ sudo systemctl status mongod

配置MongoDB

$ mongo

新建admin数据库

> use admin
创建admin的用户

> db.createUser( { user: "admin", pwd: "这里是你的密码", roles: [ { role: "readWriteAnyDatabase", db: "admin" }, { role: "userAdminAnyDatabase", db: "admin" } ] } )  
添加一个nodebb数据库
> use nodebb
> db.createUser( { user: "nodebb", pwd: "<Enter a secure password>", roles: [ { role: "readWrite", db: "nodebb" }, { role: "clusterMonitor", db: "admin" } ] } )
退出命令行
> quit()

在 /etc/mongod.conf 文件中配置以下东西以确保数据库认证的安全性
在文件最后面添加即可

security:
  authorization: enabled

重启mongodb 并使用新创建的admin用户登录

$ sudo systemctl restart mongod
$ mongo -u admin -p 密码 --authenticationDatabase=admin

安装 git用来clone NodeBB

$ sudo apt-get install -y git
$ git clone -b v1.10.x https://github.com/NodeBB/NodeBB.git nodebb
$ cd nodebb
$ ./nodebb setup

安装过程中需要注意的是
This looks like a new installation, so you’ll have to answer a few questions about your

environment before we can proceed.
Press enter to accept the default setting (shown in brackets).
URL used to access this NodeBB (http://localhost:4567) 回车
Please enter a NodeBB secret (8a133a6b-ac14-4889-bfbf-96110ce78b5e) 回车
Which database to use (mongo) 回车
2018-08-19T02:49:42.937Z [5770] - info:
Now configuring mongo database:
MongoDB connection URI: (leave blank if you wish to specify host, port, username/password

and database individually)
Format: mongodb://[username:password@]host1[:port1][,host2[:port2],…[,hostN[:portN]]][/

[database][?options]] 回车
Host IP or address of your MongoDB instance (127.0.0.1) 回车
Host port of your MongoDB instance (27017) 回车
MongoDB username 输入 admin
Password of your MongoDB database 输入 数据库密码
MongoDB database name (nodebb) 数据库名输入 admin
2018-08-19T02:53:29.567Z [5770] - info: [database] Checking database indices.
2018-08-19T02:53:29.840Z [5770] - info: [database] Checking database indices done!
Configuration Saved OK
Populating database with default configs, if not already set…
2018-08-19T02:53:38.935Z [5770] - warn: [cache-buster] could not read cache buster

message=ENOENT: no such file or directory, open ‘/mnt/NodeBB/build/cache-buster’,

stack=Error: ENOENT: no such file or directory, open ‘/mnt/NodeBB/build/cache-buster’,

errno=-2, code=ENOENT, syscall=open, path=/mnt/NodeBB/build/cache-buster
Enabling default theme: nodebb-theme-persona
No categories found, populating instance with default categories
2018-08-19T02:53:40.604Z [5770] - warn: No administrators have been detected, running

initial user setup

Administrator username 输入 admin
Administrator email address 输入 email
Password 输入 nodebb
Confirm Password 输入 nodebb
Creating welcome post!
Enabling default plugins
2018-08-19T02:54:31.698Z [5770] - info: [install/defaultPlugins] customDefaults
2018-08-19T02:54:31.699Z [5770] - info: [install/enableDefaultPlugins] activating default

plugins 0=nodebb-plugin-composer-default, 1=nodebb-plugin-markdown, 2=nodebb-plugin-

mentions, 3=nodebb-widget-essentials, 4=nodebb-rewards-essentials, 5=nodebb-plugin-

soundpack-default, 6=nodebb-plugin-emoji, 7=nodebb-plugin-emoji-android

启动nodebb

$ ./nodebb start

安装nginx

$ sudo add-apt-repository ppa:nginx/stable
$ sudo apt-get update
$ sudo apt-get install -y nginx
检查结果
$ nginx -v
启动nginx
$ sudo systemctl start nginx
$ sudo systemctl status nginx
配置域名
$ cd /etc/nginx/sites-available
$ sudo nano forum.example.com # config entered into file and saved
$ cd ../sites-enabled
$ sudo ln -s ../sites-available/forum.example.com

Below is an example configuration for NodeBB running on port 4567.

server {
    listen 80;

    server_name forum.example.com;

    location / {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Host $http_host;
        proxy_set_header X-NginX-Proxy true;

        proxy_pass http://127.0.0.1:4567;
        proxy_redirect off;

        # Socket.IO Support
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}

重启nginx即可
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值