搭建leanote服务器

0 需要下载的文件

搭建leanote服务器_第1张图片
图0-1需要下载的文件

1 说明

这里单独的创建了一个leanote文件夹,所有的配置等都放在这个文件夹中
/home/flannery/leanote

2 golang的安装

2.1 下载golang

搭建leanote服务器_第2张图片
直接从百度搜索

国内访问外网比较慢,直接访问Golang中国就可以了.

搭建leanote服务器_第3张图片
golang中国主页

在主页选择下载->Go便可以进入下载主页.

搭建leanote服务器_第4张图片
下载主页

下载的结果请参照图0-1中的go1.6.4.linux-amd64.tar.gz

2.2 安装golang

2.2.1 解压文件

$> cd /home/flannery/leanote
$> tar -xzvf go1.6.4.linux-amd64.tar.gz

解压出一个go文件夹.

2.2.2 创建一个gopackage文件夹

$> mkdir -p /home/flannery/leanote/gopackage

# 并在gopackage中添加一个bin文件夹
$> mkdir -p /home/flannery/leanote/gopackage/bin

2.2.3 编辑系统的配置文件/etc/profile

sudo gedit /etc/profile

将下列代码加入到文件末尾
export GOROOT=/home/flannery/leanote/go
export GOPATH=/home/flannery/leanote/gopackage
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

2.2.4 加载最新的配置文件

source /etc/profile

2.2.5 查看是否配置成功

go version

2.2.6 显示如下信息说明配置成功

go version go1.6.4 linux/amd64

3 生成go项目

3.1 下载leanote-all-master.zip

$> wget https://github.com/leanote/leanote-all/archive/master.zip
$> unzip master.zip
$> cp -r ./master/src /home/user1/gopackage

3.2 生成revel项目

$> go install github.com/revel/cmd/revel

4 安装Mongodb

4.1 下载Mongodb

64-bit linux Mongodb 3.0.1: [https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.0.1.tgz](https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.0.1.tgz)

现在的Mongodb下载时64位的,上面的链接地址我是可以下载的, 如果不能下载请访问Mongodb官网

4.2 安装Mongodb

# 解压文件
$> cd /home/flannery/leanote/
$> tar -xzvf mongodb-linux-x86_64-3.0.1.tgz/

4.2 将命令路径写入配置文件

$> sudo gedit /etc/profile

export PATH=$PATH:/home/flannery/mongodb-linux-x86_64-3.0.1/bin

$> source /etc/profile

4.3 测试Mongodb

# 在此目录下 /home/flannery/leanote/mongodb-linux-x86_64-3.0.1/bin
$> ./mongod --dbpath /home/flannery/leanote/data/ &

开启两一个终端,测试是否连接成功

$> mongo
> show dbs

5 导入初始化数据

$> mongorestore -h localhost -d leanote --dir /home/$USER/gopackage/src/github.com/leanote/leanote/mongodb_backup/leanote_install_data/

在我的配置中是

flannery@flannery ~/leanote/mongodb-linux-x86_64-3.0.1/bin $ ./mongorestore -h localhost -d leanote --dir /home/flannery/leanote/gopackage/src/github.com/leanote/leanote/mongodb_backup/leanote_install_data/
2017-02-21T09:58:51.848+0800    building a list of collections to restore from /home/flannery/leanote/gopackage/src/github.com/leanote/leanote/mongodb_backup/leanote_install_data/ dir
2017-02-21T09:58:51.850+0800    reading metadata file from /home/flannery/leanote/gopackage/src/github.com/leanote/leanote/mongodb_backup/leanote_install_data/note_content_histories.metadata.json
2017-02-21T09:58:51.850+0800    restoring leanote.note_content_histories from file /home/flannery/leanote/gopackage/src/github.com/leanote/leanote/mongodb_backup/leanote_install_data/note_content_histories.bson
2017-02-21T09:58:51.851+0800    reading metadata file from /home/flannery/leanote/gopackage/src/github.com/leanote/leanote/mongodb_backup/leanote_install_data/note_contents.metadata.json
2017-02-21T09:58:51.851+0800    restoring leanote.note_contents from file /home/flannery/leanote/gopackage/src/github.com/leanote/leanote/mongodb_backup/leanote_install_data/note_contents.bson
2017-02-21T09:58:51.851+0800    reading metadata file from /home/flannery/leanote/gopackage/src/github.com/leanote/leanote/mongodb_backup/leanote_install_data/configs.metadata.json
2017-02-21T09:58:51.867+0800    restoring leanote.configs from file /home/flannery/leanote/gopackage/src/github.com/leanote/leanote/mongodb_backup/leanote_install_data/configs.bson
2017-02-21T09:58:52.141+0800    restoring indexes for collection leanote.note_contents from metadata
2017-02-21T09:58:52.141+0800    reading metadata file from /home/flannery/leanote/gopackage/src/github.com/leanote/leanote/mongodb_backup/leanote_install_data/attachs.metadata.json
2017-02-21T09:58:52.142+0800    restoring leanote.attachs from file /home/flannery/leanote/gopackage/src/github.com/leanote/leanote/mongodb_backup/leanote_install_data/attachs.bson
2017-02-21T09:58:52.142+0800    restoring indexes for collection leanote.note_content_histories from metadata

~~~

6. 运行 Leanote

$> revel run github.com/leanote/leanote
# 有可能遇到这样的问题,其实我也很纳闷.其实是没有那个命令路径.
revel:未找到命令
# 解决方法
$>source /etc/profile就好了

7. 如果这时显示下面的界面说明成功了,如果没有请重新按上面的过程走一遍.

搭建leanote服务器_第5张图片
成功界面

官网配置文件

你可能感兴趣的:(搭建leanote服务器)