搭建gitbook 和 访问权限认证

相信你们都或多或少的都接触过gitbook。gitbook 首先是一个软件,正如上面定义的那样,它使用 Git 和 Markdown 来编排书本,若是用户没有听过 Git 和 Markdown,那么 gitbook 可能不适合你。废话很少说,干起来。

1 gitbook安装

1.1 安装npm包html

$ npm install gitbook -g

1.2 初始化项目nginx

$ mkdir gitbook 新建目录
  $ cd gitbook
  $ gitbook init
  
  目录
  gitbook/
  ├── README.md
  └── SUMMARY.md

1.3 起服务git

$ gitbook serve

1.4 打开浏览器 npm

能够用浏览器打开 http://127.0.0.1:4000浏览器

1.5 生产文件app

$ gitbook build

2 登陆权限认证

搭建就完成了,可是有一下内部文档,不想公布出去,怎么办,这个网上没有答案,可是方法老是有的,那就是nginx

2.1 用到nginx认证模块ui

server {
   listen 80;
   server_name www.host.com ;             # 域名注意不要加协议
   location / {
   root  html/blog;                        #根  静态文件目录
   index index.html index.htm;
   auth_basic     "pleas you password";    # nginx 认证用户和密码
   auth_basic_user_file htpasswd;          # nginx认证文件目录  能够随意指定 
}

2.2 由于要用到密码,并且是加密的,全部引入httpd模块加密

$ yum -y install httpd  
  $ htpasswd -bc /applocation/nginx/conf/htpasswd qiyun 123456  #生产密码文件,若是不能写入,就建立好文件,在执行命令

2.3 从新检测url

$ nginx -t

2.4 重启spa

$ nginx -S reload

3 案例

url: http://gitbook.beastxw.wang/

name: aaa

pwd: 123

4 图片

gitbook
clipboard.png

登陆认证
clipboard.png

5 博客

url: http://blog.beastxw.wang/2019...

相关文章
相关标签/搜索