Centos安装NodeBB论坛

  1. 使用普通用户
    由于我只有管理员账户root, 建议使用普通账户
sudo adduser sammy
sudo passwd sammy
sudo usermod -aG wheel sammy
sudo su -l sammy
sudo mkdir -p /var/www/nodebb 
sudo chown sammy /var/www/nodebb

它们分别创建用户sammy, 设置密码, 加入管理员组. 切换到sammy, 创建目录, 修改目录权限

  1. 安装nodebb
sudo yum -y update
sudo yum -y install epel-release
sudo yum -y groupinstall "Development Tools"
sudo yum -y install git redis ImageMagick npm
sudo curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
sudo source ~/.bash_profile
sudo nvm list-remote
sudo nvm install v14.18.1 # as of this writing check the result of the list-remote to see all choices
sudo systemctl start redis
sudo systemctl enable redis
cd /var/www
git clone -b v2.x https://github.com/NodeBB/NodeBB nodebb
cd nodebb
./nodebb setup

在首次更新后, 会要求配置nodebb, 如下:

URL used to access this NodeBB (http://localhost:4567) ENTER
Please enter a NodeBB secret (42a724d8-5495-41cb-a4e8-caf3ed04c1a4) ENTER
Which database to use (mongo) redis
Now configuring redis database:
prompt: Host IP or address of your Redis instance: (127.0.0.1) ENTER
prompt: Host port of your Redis instance: (6379) ENTER
prompt: Password of your Redis database: ENTER
prompt: Which database to use (0..n): (0) ENTER

若没有什么问题, 则完成安装. 使用

./nodebb start

理论上这里会有管理员邮件、用户名、密码问题提示, 但是我没看到. 事实上, 我如果先设置了nginx, 则可以通过访问网站, 设置这些管理员事项.

  1. 开机启动nodebb
    使用pm2守护nodebb进程.并且设置开机启动.
sudo npm install pm2@latest -g
sudo npm install -g [email protected]
pm2 start app.js --watch --name nodebb
pm2 save
pm2 startup
  1. 安装nginx
sudo yum install nginx

编辑配置文件/etc/share/config.d/nodebb.conf

sudo vim /etc/share/config.d/nodebb.conf

录入

server {
        listen       443 ssl http2;
        listen       [::]:443 ssl http2;
        server_name  www.example.com;
        root /var/www/nodebb/public/;

        client_max_body_size 8m;
        gzip on;
        gzip_min_length 1000;
        gzip_types application/json text/css application/x-javascript;


        ssl_certificate "/root/v2ray.pem";
        ssl_certificate_key "/root/v2ray.key";
        ssl_session_cache shared:SSL:1m;
        ssl_session_timeout  10m;
        ssl_ciphers HIGH:!aNULL:!MD5;
        ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
        ssl_prefer_server_ciphers on;

        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;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
        }
}
server {
        if ($host = www.example.com) {
                return 301 https://$host$request_uri;
        } 
        listen 80;
        server_name www.example.com;
        return 404; 
}
  1. 邮件可以正常使用, 例如新用户注册会收到激活邮件.
  2. 使用mathjax处理数学公式, 参考https://community.nodebb.org/topic/8278/mathjax-support/16

参考文献

  1. https://docs.nodebb.org/installing/os/centos/
  2. https://www.digitalocean.com/community/tutorials/how-to-add-and-delete-users-on-a-centos-7-server
  3. https://www.hugeserver.com/kb/how-install-nodebb-redis-database/
  4. 重置管理员密码

你可能感兴趣的:(Centos安装NodeBB论坛)