Using Gitbook to Build Personal Knowledge Archiving System

I. Prerequisites

1. The Linux Server recommends to choose CentOS 7_64 bit OS, and the unregistered domain name suggests to choose Diitalocean Singapore.  
  Nodes are deployed.
2. Registration Requirements Link:
3.Everyone you refer gets $100 in credit over 60 days. 
4. Suggestions for choosing models:
  $5 /month
  $0.007 /hour
  1 GB / 1 CPU
  25 GB SSD disk
  1000 GB transfer

5. If you want to be cheaper, you can come here at
6.Nginx is now the latest Stable version

It is a Node.js-based command-line tool.  

  npm is a package management tool in the JavaScript world, and is the default package management tool for Node.js platform. 
  Specifically, you can refer to
  Here, n is mainly used for node.js version management.

II. Installation of Nginx

(1) Installation of dependency Libraries

yum install gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel wget
 Installing nginx requires compiling the source code downloaded from the official website first, and compiling depends on the gcc environment.
PCR E is a Perl library, including a Perl-compatible regular expression library. nginx's http module uses pcre  
To parse regular expressions.
nginx uses zlib to gzip the contents of http packages.
OpenSSL is a powerful secure socket layer cryptographic library, which includes the main cryptographic algorithms. 
Commonly used key and certificate encapsulation management functions and SSL protocol.

(2) Installation of Nginx

tar zvfx nginx-1.14.2.tar.gz
cd nginx-1.14.2
./configure --prefix=/usr/local/nginx
make install 
cd ..
./configure It is used to detect the target features of your installation platform.,Check if the current environment is full  
//It is necessary to install software dependencies and so on.
make It is compiled from Makefile Read the instructions and compile them.
make install It is used for installation, and it also comes from Makefile Read the instructions and install them to the specified location.

Installation of Gitbook

yum install -y npm // Package management tools
npm install -g n // The node.js management tool can switch versions and upgrade versions at will.
n latest // Install node.js and select the latest version here
npm install gitbook-cli -g // Install gitbook command line tools
gitbook --version // View Version
mkdir -p /data/gitbook/myblog 
cd /data/gitbook/myblog && gitbook init // Initial gitbook
gitbook build (After compilation, the myblog Lower Generation_book Next we configure the directory Nginx Point to this directory)

// [The following two understandings are enough]
npm update gitbook-cli -g (To update gitbook)
npm uninstall gitbook-cli -g (uninstall gitbook)

IV. Configuring Nginx

vim /usr/local/nginx/conf/nginx.conf

server {
    listen 80;
    root   /data/gitbook/myblog/_book/;
    index  index.php index.html index.htm;
    charset utf-8;
/usr/local/nginx/sbin/nginx -s reload(Reload)
killall /usr/local/nginx/sbin/nginx(Close)
Domain name resolution is no longer written separately because there is only one host configuration on the host that can be accessed directly by entering http://ip
 If you can't access, please check whether port 80 is open and set access permission to
Close the firewall (system CTL stop firewalld & System CTL disable firewalld)

5. Automatic update settings


#unset GIT_DIR
cd $MyBlog
UpdateMyBlog=`git pull`
if [[ ${UpdateMyBlog} = "Already up-to-date." ]];then
    echo "Already the latest code does not need to be compiled and updated"
    # Download the contents of remote libraries without merging
    cd $MyBlog
    git fetch --all

    # Point HEAD to the latest version just downloaded
    git reset --hard origin/master
    echo "Code pull-out update completed!"
    cd $MyBlog/myblog
    /usr/local/bin/gitbook build
    echo "Code built!"
Add crontab timer task automatic detection pull to update compilation (-x is debug mode).
*/1 * * * * /bin/bash -x /data/gitbook/   
    >> /tmp/gitbook.log 2>&1

VI. gitbook Platform Installation Guide

Installation Guidelines for CentOS 7 Environment

yum install -y npm
npm install -g n
npm install -g pm2
n latest
npm install gitbook-cli -g
gitbook --version

gitbook init
gitbook build


(2) Installation Guidelines under MAC

Download and install NODE
sudo npm install -g n
sudo n latest
sudo npm install gitbook-cli -g
sudo gitbook --version


Keywords: Web Server Nginx npm sudo git

Added by jmicozzi on Wed, 04 Sep 2019 09:36:30 +0300