教程改编自官方文档,官方文档地址:https://docs.nodebb.org/en/latest/installing/os/centos.html
yum -y update
yum -y install epel-release (centos6不用运行这条命令)
yum -y groupinstall "Development Tools"
yum -y install git redis ImageMagick npm
curl https://raw.githubusercontent.com/creationix/nvm/v0.13.1/install.sh | bash
source ~/.bash_profile
export NVM_NODEJS_ORG_MIRROR=http://npm.taobao.org/mirrors/node
export NVM_IOJS_ORG_MIRROR=http://npm.taobao.org/mirrors/iojs
nvm list-remote
nvm install v6.0.0
npm install -g cnpm --registry=https://registry.npm.taobao.org
systemctl start redis
systemctl enable redis
cd /path/to/nodebb/install/location (可不运行,直接下载至根目录)
git clone -b v1.x.x https://github.com/NodeBB/NodeBB nodebb
cd nodebb
cnpm install
一般几分钟就搞定了
./nodebb setup
一路向下就ok了,记得将数据库改为redis,默认设置是mongo,然后运行'./nodebb start',ok,访问你的网址:4567,看是否成功了。
yum install nginx
cd /etc/nginx/conf.d
nano example.conf
规则如下(www重定向至no-www,如果不需要,可以自己修改)
server {
listen 80;
server_name www.example.com;
return 301 http://example.com$request_uri;
}
server {
listen 80;
server_name 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
service nginx restart
如果出现如下错误
nginx: [emerg] could not build server_names_hash, you should increase server_names_hash_bucket_size: 32
nginx: configuration file /etc/nginx/nginx.conf test failed
修改nginx.conf,在http{}添加
server_names_hash_bucket_size 64;
保存,退出,启动nginx