蚂蚁笔记私有部署
說明
其實官方的教程中已經(jīng)寫得很清楚了,我寫這個主要是為了記錄一下我自己當時安裝的過程,方便后續(xù)查詢
官方文檔請查閱:https://github.com/leanote/leanote/wiki
環(huán)境要求
- CentOS6.5+Nginx+MongoDB
- 最小配置:16G內(nèi)存+4CPU+500G硬盤
- 推薦配置:32G內(nèi)存+4CPU+1T硬盤
安裝過程
- 安裝 CentOS 6.5
最小化安裝,分區(qū)如下,推薦基于LVM,后面維護比較方便:
/boot 500Mswap 8G/ 20G/data 剩下所有- 系統(tǒng)優(yōu)化
關(guān)閉SELinux
sed -i 's/SELINUX=enforcing/SELINUX=disabled/'/etc/s精簡啟動項
LANG=en for root in `chkconfig --list|grep 3:on|awk '{print 1}'`;do chkconfig --level 3 root off;done for root in crond network rsyslog sshd iptables;do chkconfig --level 3 $root on;done chkconfig --list|grep 3:on安裝軟件
安裝Nginx
安裝其他軟件
yum -y install vim wget curl lsof net-tools openssl- 安裝Mongodb
編輯mongodb的YUM源
#vim /etc/yum.repos.d/mongodb-org-3.4.repo #添加入一下內(nèi)容 [mongodb-org-3.4] name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.4/x86_64/ gpgcheck=1 enabled=1 gpgkey=https://www.mongodb.org/static/pgp/server-3.4.as安裝mongodb
yum -y install mongodb-org- 自定義Mondodb數(shù)據(jù)庫
修改數(shù)據(jù)庫存儲路徑,將dbpath自定義成自己的data分區(qū),首先需要創(chuàng)建目錄并賦予權(quán)限
mkdir -p /data/db chown -Rf mongod:mongod /data/db chmod -Rf 755 /data/db更改MongoDB數(shù)據(jù)庫存儲路徑,修改dbPath
# vim /etc/mongod.conf ... systemLog:destination: filelogAppend: truepath: /var/log/mongodb/mongod.log# Where and how to store data.storage:dbPath: /data/db/ //我們需要指定庫文件的存放目錄journal:enabled: true# how the process runsprocessManagement:fork: true # fork and run in backgroundpidFilePath: /var/run/mongodb/mongod.pid # location of pidfile# network interfacesnet:port: 27017bindIp: 127.0.0.1 ...- 啟動Mongodb并加入開機自啟
- 部署螞蟻筆記
下載螞蟻筆記
cd /data wget https://sourceforge.net/projects/leanote-bin/files/2.5/leanote-linux-amd64-v2.5.bin.tar.gz解壓文件
tar -zxvf leanote-linux-amd64-v2.5.bin.tar.gz導入初始化數(shù)據(jù)庫
mongorestore -h localhost -d leanote --dir /data/leanote/mongodb_backup/leanote_install_data/給mongodb添加數(shù)據(jù)庫用戶
mongo 首先切換到leanote數(shù)據(jù)庫下 > use leanote; 添加一個用戶root, 密碼是abc123,這個密碼是可以自定義的 > db.createUser({user: 'root',pwd: 'abc123',roles: [{role: 'dbOwner', db: 'leanote'}]}); 測試下是否正確 > db.auth("root", "abc123");1 返回1表示正確修改app.conf
# vim /data/leanote/conf/app.conf ...db.host=localhostdb.port=27017db.dbname=leanotedb.username=rootdb.password=abc123 ...重啟數(shù)據(jù)庫服務(wù)
service mongod restart嘗試運行
bash /data/leanote/bin/run.sh如果終端提示如下就說明配置是正確的
... TRACE 2013/06/06 15:01:27 watcher.go:72: Watching: /home/life/leanote/bin/src/github.com/leanote/leanote/conf/routes Go to /@tests to run the tests. Listening on :9000 ...- 嘗試訪問,記得先關(guān)閉下防火墻
恭喜你, 打開瀏覽器輸入: http://localhost:9000體驗leanote吧!
- 配置支持https
創(chuàng)建證書
首先,創(chuàng)建證書和私鑰的目錄 # mkdir -p /etc/nginx/cert # cd /etc/nginx/cert 創(chuàng)建服務(wù)器私鑰,命令會讓你輸入一個口令: # openssl genrsa -des3 -out nginx.key 2048 創(chuàng)建簽名請求的證書(CSR): # openssl req -new -key nginx.key -out nginx.csr 在加載SSL支持的Nginx并使用上述私鑰時除去必須的口令: # cp nginx.key nginx.key.org # openssl rsa -in nginx.key.org -out nginx.key 最后標記證書使用上述私鑰和CSR: # openssl x509 -req -days 365 -in nginx.csr -signkey nginx.key -out nginx.crt配置Nginx
配置nginx.conf
# vim /etc/nginx/nginx.conf 添加入一下內(nèi)容 #本配置只有http部分, 不全, 詳細配置請百度Nginx相關(guān)知識 http {include /etc/nginx/mime.types;default_type application/octet-stream;upstream note.cloud.top {server localhost:9000;}# httpserver{listen 80;server_name note.cloud.top;# 強制https# 如果不需要, 請注釋這一行rewriterewrite ^/(.*) https://note.cloud.top/$1 permanent;location / {proxy_pass http://note.cloud.top;proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;}}# httpsserver{listen 443 ssl;server_name note.cloud.top;ssl_certificate /etc/nginx/cert/nginx.crt; # 修改路徑, 到nginx.crt, 下同ssl_certificate_key /etc/nginx/cert/nginx.key;location / {proxy_pass http://note.cloud.top;proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;}}}啟動Nginx
service nginx start chkconfig nginx on- 筆記系統(tǒng)開機自啟
注意
官方文檔并沒有給出這項設(shè)置,其實最簡單的辦法就是向rc.local文件中添加一條命令,開機自動執(zhí)行,但是這里推薦使用supervisor服務(wù)進行管理,supervisor的詳細介紹見:http://www.supervisord.org/**
方法1:
# vim /etc/rc.d/rc.local 添加下面的內(nèi)容,這樣的化開機后就不會有影響 nohup bash /data/leanote/bin/run.sh &方法2-推薦使用
使用supervisor服務(wù)進行管理的優(yōu)點是服務(wù)異常后自動重啟,可靠性較高
- 安裝supervisor服務(wù)
- 配置supervisor
logfile我們定義到磁盤黑洞中,就不用占用磁盤的空間,同時減少部分磁盤IO開銷
- 啟動supervisor服務(wù)并添加到開機自啟中
- 防火墻配置
- 其它配置
修改leanote運行端口
比如想以8080端口啟動.修改conf/app.conf:
http.port=8080 site.url=http://note.cloud.top:8080請重啟Leanote, 使用http://note.cloud.top:8080
綁定域名
提示:
site.url其實是自己可以自定義的,因為在瀏覽器中我們登錄注銷后url會自動變成這個語句設(shè)置的值,所以務(wù)必設(shè)置正確。
site.url=http://note.cloud.top 或 site.url=https://note.cloud.top 請重啟Leanote, 使用http://note.cloud.top 或者 https:note.cloud.top 進行訪問轉(zhuǎn)載于:https://www.cnblogs.com/tchroot/p/7732754.html
總結(jié)
- 上一篇: jfinal上传图片,生成日期文件夹,图
- 下一篇: 【shell】shell编程(一)-入门