环境设置

时区设置:

tzselect
选择:5--9--1--1
vim /etc/profile
添加:
TZ='Asia/Shanghai'; export TZ

系统更新、工具安装

yum update
yum install vim

安装配置

Mongodb安装

vim /etc/yum.repos.d/mongodb-org-4.0.repo
添加以下内容:
[mongodb-org-4.0]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.0/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc
安装:
yum install -y mongodb-org
启动自启:
service mongod start
chkconfig mongod on

leanote安装

  • 下载linux二进制包到服务器/opt下解压,得到leanote文件夹
mongorestore -h localhost -d leanote --dir /opt/leanote/mongodb_backup/leanote_install_data/
bash /opt/leanote/bin/run.sh
  • 给leanote添加数据库访问用户
mongo
use leanote;
db.createUser(
   {
     user: "user",
     pwd: "passowrd",
     roles: [ "readWrite", "dbAdmin" ]
   }
);
  • 修改配置文件,采用用户连接leanote
vim /opt/leanote/conf/app.conf
username = user
password = passowrd
  • 重启leanoe即可
  • 开启MongoDB的auth
vim /etc/mongodb.conf
添加:
security:
  authorization: enabled
  • 重启mongodb服务

Nginx

  • 安装
rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
yum install nginx
  • 配置
vim /etc/nginx/nginx.conf
http{}中添加:
upstream www.jbstudy.cn {
    server localhost:9000;
    }
vim /etc/nginx/conf.d/default.conf
替换为:
# http
server
{
    listen 80;
    server_name www.jbstudy.cn;

    # 强制https
    # 如果不需要, 请注释这一行rewrite
    rewrite ^/(.*) https://www.jbstudy.cn/$1 permanent;

    location / {
        proxy_pass http://www.jbstudy.cn;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        client_max_body_size 10m; #设置最大上传文件大小
    }
}

# https
server
{
    listen 443 ssl;
    server_name www.jbstudy.cn;
    ssl_certificate /root/cert-1523341295544_www.jbstudy.cn.crt;
    ssl_certificate_key /root/cert-1523341295544_www.jbstudy.cn.key;
    location / {
        proxy_pass http://www.jbstudy.cn;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        client_max_body_size 10m; #设置最大上传文件大小
    }
}

修改leanoe安全配置

vim /opt/leanote/conf/app.conf
http.addr=127.0.0.1
http.port=9000
site.url=http://www.jbstudy.cn