如何部署gitbook
npm install yarn -g 安装yarnyarn global add gitbook安装gitbook
·
环境:
部署gitbook的系统
centos linux 64
依赖:
以下命令如果not found,须预先安装.
git command not found
—>yum install git
npm command not found
—>yum install npm
开始:
npm install yarn -g
安装yarnyarn global add gitbook
安装gitbookyarn global add gitbook-cli
安装客户端依赖
以上,准备结束。
以 https://github.com/fwhezfwhez/test_gitbook 为例.
部署一本书
cd /home/$ssh_username/
进入你ssh的用户名的目录mkdir gitbooks
创建一个gitbooks文件夹存放所有的书籍git clone https://github.com/fwhezfwhez/test_gitbook.git book1
下载该书籍cd book1
进入书籍目录gitbook serve .
部署
结束,即可通过你原本的电脑浏览器,输入 http://服务器host:4000
访问
最后,如何同时部署多本书.
每本gitbook需要占用2个端口,一个是lrport,一个是服务port,lrport我不知道是啥,知道的回我一下
如果部署了上述书籍以后,需要部署另一本书,可以执行以下:
cd /home/$ssh_username/gitbooks/
git clone https://github.com/fwhezfwhez/test_gitbook.git book2
虽然用了同一本书,但是是两个文件夹,部署两次
cd book2
gitbook serve . --lrport 35730 --port 4001
结束,即可通过你原本的电脑浏览器,输入 http://服务器host:4001
访问
再最后,如何把部署的窗口后台运行
nohup <command> &
比如
nohup gitbook serve . &
示例
本地书籍,部署到服务器上
- 确保目的地不存在文件
ssh fwhez@100.100.100.100
# 或者 rm -rf /home/fwhez/doc,无权限时,用mv
mv /home/fwhez/doc /tmp/doc
- 将本地书记,scp进服务器指定位置
scp -r /doc fwhez@100.100.100.100:/home/fwhez/doc
ssh 100.100.100.100
docker run -itd --rm -p 4001:4001 -p 35730:35730 -v /home/fwhez/doc:/doc fellah/gitbook:latest gitbook serve /doc/. --lrport 35730 --port 4001
前置
- 需要安装docker-ci,并且
docker pull fellah/gitbook:latest
- 需要nginx,将域名解析到服务器ip,nginx配置80/443定向到4001
doc.conf
# http 80
server {
listen 80;
server_name xxx.xxxx.com;
root /home/fwhez/doc;
# request header
proxy_set_header Host $http_host;
proxy_set_header Cookie $http_cookie;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
location / {
proxy_pass http://localhost:4001;
}
}
# https 443
server {
listen 443 ssl;
server_name xxxx.xxx.com;
root /usr/share/nginx/html;
ssl_certificate "/etc/nginx/certs/xyx.crt";
ssl_certificate_key "/etc/nginx/certs/xyx.key";
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 10m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
# request header
proxy_set_header Host $http_host;
proxy_set_header Cookie $http_cookie;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
location / {
proxy_pass http://localhost:4001;
}
更多推荐
已为社区贡献4条内容
所有评论(0)