搭建note
1 --初始環(huán)境欧芽,啟動容器
在服務器家目錄拉取mynote代碼:
git clone git@github.com:RonnyJiang/mynote.git
切到note分支
git checkout --track origin/note
把leanote-linux-amd64-v2.5.bin.tar.gz 包放到倉庫码倦,并提交
然后將包解壓乎完,在.gitignore中加上leanote/mongodb_backup砍聊,讓初始化數(shù)據(jù)不提交到倉庫中,然后提交兼砖。
然后運行docker容器蔚润,將mynote掛載到容器的/home/ronny/mynote目錄上磅氨,端口映射為8090,端口已經(jīng)開放嫡纠,外網(wǎng)可以訪問烦租。
cmd如下:
docker run -it -v /home/ronny/mynote:/home/ronny/mynote -p 8090:8090 --name noteserver ronnyjiang/private:noteserver /bin/bash
2? --測試mongodb安裝
在容器創(chuàng)建目錄/home/ronny/notedata用于存放mongodb數(shù)據(jù):
用以下命令啟動mongod:
mongod --dbpath /home/ronny/notedata
這時mongod已經(jīng)啟動,ps -aux 可以看到這個deamon?
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
ronny 43 0.9 6.5 361132 66380 ? Sl+ 17:04 0:02 mongod --dbpath /home/ronny/notedata
重新打開一個終端, 鍵入mongo進入交互程序:
$> mongo
> show dbs
...數(shù)據(jù)庫列表
mongodb安裝到此為止, 下面為mongodb導入leanote初始數(shù)據(jù)货徙。
3. 導入初始數(shù)據(jù)
leanote初始數(shù)據(jù)存放在/home/ronny/mynote/leanote/mongodb_backup/leanote_install_data中左权。
打開終端, 輸入以下命令導入數(shù)據(jù)痴颊。
mongorestore -h localhost -d leanote --dir?/home/ronny/mynote/leanote/mongodb_backup/leanote_install_data
現(xiàn)在在mongodb中已經(jīng)新建了leanote數(shù)據(jù)庫, 可用命令查看下leanote有多少張"表":
$> mongo
> show dbs # 查看數(shù)據(jù)庫
leanote 0.203125GB
local 0.078125GB
> use leanote # 切換到leanote
switched to db leanote
> show collections # 查看表
files
has_share_notes
note_content_histories
note_contents
....
ronny@88446028a8c0:~/notedata$ mongo
MongoDB shell version: 3.0.1
connecting to: test
Server has startup warnings:
2017-11-08T17:05:24.732+0800 I CONTROL? [initandlisten]
2017-11-08T17:05:24.732+0800 I CONTROL? [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2017-11-08T17:05:24.732+0800 I CONTROL? [initandlisten] **? ? ? ? We suggest setting it to 'never'
2017-11-08T17:05:24.732+0800 I CONTROL? [initandlisten]
2017-11-08T17:05:24.732+0800 I CONTROL? [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2017-11-08T17:05:24.732+0800 I CONTROL? [initandlisten] **? ? ? ? We suggest setting it to 'never'
2017-11-08T17:05:24.732+0800 I CONTROL? [initandlisten]
> show dbs
leanote? 0.078GB
local? ? 0.078GB
> use leanote
switched to db leanote
> show collections
albums
attachs
blog_comments
blog_likes
blog_singles
configs
email_logs
files
find_pwds
group_users
groups
has_share_notes
leanote.ShareNotes
leanote.has_share_notes
note_content_histories
note_contents
note_images
note_tags
notebooks
notes
reports
sessions
share_notebooks
share_notes
suggestions
system.indexes
tag_count
tags
themes
tokens
traffics
user_blogs
users
>
初始數(shù)據(jù)的users表中已有2個用戶:
user1 username: admin, password: abc123 (管理員, 只有該用戶才有權管理后臺, 請及時修改密碼)
user2 username: demo@leanote.com, password: demo@leanote.com (僅供體驗使用)
我們可以直接看數(shù)據(jù)庫
ronny@88446028a8c0:~/notedata$ mongo
MongoDB shell version: 3.0.1
connecting to: test
Server has startup warnings:
2017-11-08T17:05:24.732+0800 I CONTROL? [initandlisten]
2017-11-08T17:05:24.732+0800 I CONTROL? [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2017-11-08T17:05:24.732+0800 I CONTROL? [initandlisten] **? ? ? ? We suggest setting it to 'never'
2017-11-08T17:05:24.732+0800 I CONTROL? [initandlisten]
2017-11-08T17:05:24.732+0800 I CONTROL? [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2017-11-08T17:05:24.732+0800 I CONTROL? [initandlisten] **? ? ? ? We suggest setting it to 'never'
2017-11-08T17:05:24.732+0800 I CONTROL? [initandlisten]
> show dbs
leanote? 0.078GB
local? ? 0.078GB
> use leanote
switched to db leanote
> show collections
albums
attachs
blog_comments
blog_likes
blog_singles
configs
email_logs
files
find_pwds
group_users
groups
has_share_notes
leanote.ShareNotes
leanote.has_share_notes
note_content_histories
note_contents
note_images
note_tags
notebooks
notes
reports
sessions
share_notebooks
share_notes
suggestions
system.indexes
tag_count
tags
themes
tokens
traffics
user_blogs
users
> db.users.find()
{ "_id" : ObjectId("5368c1aa99c37b029d000001"), "CreatedTime" : ISODate("2014-05-06T11:04:10.658Z"), "Email" : "admin@leanote.com", "LeftIsMin" : false, "NoteListWidth" : 266, "NotebookWidth" : 160, "Pwd" : "e99a18c428cb38d5f260853678922e03", "Theme" : "simple", "ThirdType" : 0, "ThirdUserId" : "", "ThirdUsername" : "", "Username" : "admin", "UsernameRaw" : "admin", "Verified" : false, "mdEditorWidth" : 0, "Usn" : 200044, "Logo" : "" }
{ "_id" : ObjectId("540817e099c37b583c000001"), "CreatedTime" : ISODate("2014-09-04T07:42:24.064Z"), "Email" : "demo@leanote.com", "LeftIsMin" : false, "NoteListWidth" : 0, "NotebookWidth" : 0, "Pwd" : "84e724109bd30a935846e8302be01bd8", "Theme" : "", "ThirdType" : 0, "ThirdUserId" : "", "ThirdUsername" : "", "Username" : "demo", "UsernameRaw" : "demo", "Verified" : false, "Usn" : 200006 }
>
4. 配置leanote
leanote的配置存儲在文件conf/app.conf中赏迟。
請務必修改app.secret一項, 在若干個隨機位置處,將字符修改成一個其他的值, 否則會有安全隱患!
其它的配置可暫時保持不變, 若需要配置數(shù)據(jù)庫信息, 請參照leanote問題匯總蠢棱。
然后將leanote/conf/app.conf 添加到.gitignore锌杀,不讓別人看見app.secret
接下來再修改一下leanote/conf/app.conf中的port,改為8090
5. 運行l(wèi)eanote
注意:在此之前請確保mongodb已在運行!
新開一個窗口, 運行:
$> cd /home/ronny/mynote/leanote/bin
$> bash run.sh
最后出現(xiàn)以下信息證明運行成功:
...
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 :8090..
恭喜你, 打開瀏覽器輸入:http://localhost:8090體驗leanote吧!
按照本教程啟動Mongodb是沒有權限控制的, 如果你的Leanote服務器暴露在外網(wǎng), 任何人都可以訪問你的Mongodb并修改, 所以這是極其危險的!!!!!!!!!!! 請務必為Mongodb添加用戶名和密碼并以auth啟動, 方法請見:為mongodb數(shù)據(jù)庫添加用戶
最下面會創(chuàng)建一個leanote數(shù)據(jù)庫的用戶泻仙。并以auth方式啟動數(shù)據(jù)庫糕再。看最下面:
如果運行有問題或想要進一步配置leanote, 請參照leanote問題匯總玉转。
啟動的進程是這樣的:
ronny@88446028a8c0:~$ ps -aux
USER? ? ? PID %CPU %MEM? ? VSZ? RSS TTY? ? ? STAT START? TIME COMMAND
ronny? ? ? ? 1? 0.0? 0.1? 19908? 1352 ?? ? ? ? Ss? 16:58? 0:00 /bin/bash
ronny? ? ? 43? 0.3? 9.3 533184 94512 ?? ? ? ? Sl+? 17:04? 0:07 mongod --dbpath /home/ronny/notedata
ronny? ? ? 54? 0.0? 0.3? 19916? 3680 ?? ? ? ? Ss? 17:07? 0:00 /bin/bash
ronny? ? ? 122? 0.0? 0.3? 19704? 3256 ?? ? ? ? S+? 17:37? 0:00 bash run.sh
ronny? ? ? 130? 0.0? 1.4? 20772 14632 ?? ? ? ? Sl+? 17:37? 0:00 /home/ronny/mynote/leanote/bin/leanote-linux-amd64 -importPath github.com/leanote/leanote
ronny? ? ? 139? 0.0? 0.3? 19904? 3660 ?? ? ? ? Ss? 17:40? 0:00 /bin/bash
ronny? ? ? 152? 0.0? 0.2? 17268? 2440 ?? ? ? ? R+? 17:40? 0:00 ps -aux
接下來就是修改用戶突想,然后定制note style。修該網(wǎng)頁的內(nèi)用了究抓。主要修改圖標猾担,logo,主頁刺下。
這時運行起來了绑嘹,但是有個安全隱患,我們需要為mongodb數(shù)據(jù)庫添加用戶:
像mysql一樣有root用戶, mongodb初始是沒有用戶的, 這樣很不安全, 所以要為leanote數(shù)據(jù)庫新建一個用戶來連接leanote數(shù)據(jù)庫(注意, 并不是為leanote的表users里新建用戶, 而是新建一個連接leanote數(shù)據(jù)庫的用戶, 類似mysql的root用戶).
mognodb v2與v3創(chuàng)建用戶命令有所不同
mongodb v2 創(chuàng)建用戶如下:
# 首先切換到leanote數(shù)據(jù)庫下
> use leanote;
# 添加一個用戶root, 密碼是abc123
> db.addUser("root", "abc123");
{
"_id" : ObjectId("53688d1950cc1813efb9564c"),
"user" : "root",
"readOnly" : false,
"pwd" : "e014bfea4a9c3c27ab34e50bd1ef0955"
}
# 測試下是否正確
> db.auth("root", "abc123");
1 # 返回1表示正確
mongodb v3 創(chuàng)建用戶如下:
# 首先切換到leanote數(shù)據(jù)庫下
> use leanote;
# 添加一個用戶root, 密碼是Cos*14-------
> db.createUser({
user: 'root',
pwd: 'Cos*14------',
roles: [{role: 'dbOwner', db: 'leanote'}]
});
# 測試下是否正確
> db.auth("root", "Cos*14-------");
1 # 返回1表示正確
用戶添加好后重新運行下mongodb, 并開啟權限驗證. 在mongod的終端按ctrl+c即可退出mongodb.
啟動mongodb:
$> mongod --dbpath /home/ronny/notedata?--auth
然后按ctrl+p ctrl+q 退出docker container橘茉。
接著再docker exec -it 88446028a8c0 /bin/bash 進入容器工腋,修改leanote的app.conf
還要修改配置文件: 修改 leanote/conf/app.conf:
db.host=localhost
db.port=27017
db.dbname=leanote # required
db.username=root # if not exists, please leave blank
db.password=Cos*14-------- # if not exists, please leave blank
保存后姨丈,我們在重啟leanote。因為剛剛已經(jīng)kill掉了leanote和mongod的后臺進程擅腰。所以現(xiàn)在直接運行就行了
主要是為mongodb創(chuàng)建用戶后要響響應修改app.conf中的用戶名和密碼蟋恬,需要注意的是啟動mongod需要多加一個--auth,而leanote還是僅僅進入bin目錄執(zhí)行bash ./run.sh
可以看到正常啟動
為Leanote指定超級管理員帳戶(admin用戶)
Leanote默認超級管理員為admin, 且一旦不小心修改了username則不能改回. 此時可修改配置文件app.conf, 比如指定用戶life為超級管理員, 修改或/添加一行:
adminUsername=life
修改默認語言惕鼓,打開網(wǎng)頁就顯示默認的語言筋现,這里設置為中文,修改后需要kill掉leanote進程箱歧,重新啟動,啟動后進程為
ronny@88446028a8c0:~$ ps -aux
USER? ? ? PID %CPU %MEM? ? VSZ? RSS TTY? ? ? STAT START? TIME COMMAND
ronny? ? ? ? 1? 0.0? 0.1? 19908? 1352 ?? ? ? ? Ss+? Nov08? 0:00 /bin/bash
ronny? ? ? 54? 0.0? 0.3? 19916? 3680 ?? ? ? ? Ss+? Nov08? 0:00 /bin/bash
ronny? ? ? 139? 0.0? 0.3? 19904? 3660 ?? ? ? ? Ss+? Nov08? 0:00 /bin/bash
ronny? ? ? 153? 0.0? 0.3? 19904? 3664 ?? ? ? ? Ss? 09:42? 0:00 /bin/bash
ronny? ? ? 181? 0.2 10.2 693944 103996 ?? ? ? Sl+? 09:55? 0:12 mongod --dbpath /home/ronny/notedata --auth
ronny? ? ? 192? 0.0? 0.3? 19912? 3728 ?? ? ? ? Ss+? 09:59? 0:00 /bin/bash
ronny? ? ? 230? 0.0? 0.3? 19908? 3740 ?? ? ? ? Ss? 10:22? 0:00 /bin/bash
ronny? ? ? 270? 0.0? 0.3? 19704? 3288 ?? ? ? ? S+? 10:51? 0:00 bash ./run.sh
ronny? ? ? 277? 0.0? 1.3? 19716 14092 ?? ? ? ? Sl+? 10:51? 0:00 /home/ronny/mynote/leanote/bin/leanote-linux-amd64 -importPath github.com/leanote/leanote
ronny? ? ? 283? 0.0? 0.3? 19908? 3636 ?? ? ? ? Ss? 10:51? 0:00 /bin/bash
ronny? ? ? 299? 0.0? 0.2? 17268? 2436 ?? ? ? ? R+? 11:18? 0:00 ps -aux
不錯的免費logo設計網(wǎng)站
http://www.uugai.com/logoa/yulan.php
非常好的截圖工具一膨,可以裁剪logo大小并且保持透明度呀邢,非常好!