Loading... [NodeBB][1]是一款专为现代网络构建的基于Node.js的论坛软件。 在诸多论坛系统之中,NodeBB不说最好,至少也是最好之一了。界面也是比较耐看的。 在部署上,确实稍许有些麻烦,本文中,笔者会讲述如何在CentOS7上部署NodeBB ## 准备 * CentOS 7x64服务器(RAM大于等于1G) * EPEL yum库 * root权限 * 善用Google ## 始 首先,我们应该确保CentOS是最新的,我们可以使用以下命令来做到这一点: ```shell yum -y update ``` 安装epel版本 ```shell yum -y install epel-release ``` 之后,安装依赖软件 ```shell yum -y groupinstall "Development Tools" yum -y install git redis ImageMagick ``` 通过npm安装nodejs ```shell curl https://raw.githubusercontent.com/creationix/nvm/v0.13.1/install.sh | bash source ~/.bash_profile nvm list-remote nvm install v13.8.0 # 在上一个命令所列出来的列表中挑一个比较新的 ``` 现在启动redis并将其设置为开机自启 ```shell systemctl start redis systemctl enable redis ``` 接下来,克隆NodeBB存储库: ```shell cd /path/to/nodebb/install/location git clone -b v1.13.2 https://github.com/NodeBB/NodeBB nodebb cd nodebb ``` 注意:要克隆master分支,可以使用相同的命令,但不带“ -b”选项。 安装依赖并进行基础设置 ```shell ./nodebb setup ``` 设置防火墙 ```shell firewall-cmd --zone=public --add-port=4567/tcp --permanent firewall-cmd --reload ``` 启动论坛! ```shell ./nodebb start ``` 注意,这个时候在浏览器输入地址只会得到一个500 ERROR,还需要进行web服务器(nginx,apache,caddy.....)的配置。 这里笔者选择的是通过lnmp的nginx自动脚本,这样设置https什么的比较方便。 安装nginx: ```shell wget http://soft.vpser.net/lnmp/lnmp1.6.tar.gz -cO lnmp1.6.tar.gz && tar zxf lnmp1.6.tar.gz && cd lnmp1.6 && ./install.sh nginx ``` 注意:以上命令只会安装nginx,不会安装php及mysql,如有需要请将末尾的nginx改为lnmp! 创建网址: ```shell lnmp vhost add ``` 跟着流程走,具体参考如下: ```shell Please enter domain(example: www.lnmp.org): yard.axiss.world Your domain: yard.axiss.world Enter more domain name(example: lnmp.org *.lnmp.org): Please enter the directory for the domain: yard.axiss.world Default directory: /home/wwwroot/yard.axiss.world: Virtual Host Directory: /home/wwwroot/yard.axiss.world Allow Rewrite rule? (y/n) n You choose rewrite: none Enable PHP Pathinfo? (y/n) n Disable pathinfo. Allow access log? (y/n) n Disable access log. Add SSL Certificate (y/n) y 1: Use your own SSL Certificate and Key 2: Use Let's Encrypt to create SSL Certificate and Key Enter 1 or 2: 2 It will be processed automatically. Press any key to start create virtul host... ``` 配置nginx: 用如下这段替换所有的location段,否则会有样式错误。 /usr/local/nginx/conf/ ```yaml ...... 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"; } ``` 输入域名就可以正常访问啦。 参考: https://docs.nodebb.org/installing/os/centos/ https://www.helplib.cn/yanyan/how-to-install-nodebb-on-centos-7 https://www.kancloud.cn/a632079/nodebb-cn/372106 [1]: https://nodebb.org/ Last modification:March 14, 2021 © Allow specification reprint Support Appreciate the author AliPayWeChat Like 0 原创不易,请我杯奶茶吧~