To build a GitBook environment under Centos7, you need to install several components: nodejs, gitbook, git
Among them, nodejs
can use nvm
for version switching management.
nvm is an open source tool that can switch and manage the nodejs version, among which you can look at the warehouse on Github.
Visit nvm's github, as follows:
According to the introduction, you can see the related installation script as follows:
Execute installation script
Execute curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
as follows:
[ root@server01 ~]# curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100132261001322600238900:00:050:00:05- - :- - :- - 2959=> Downloading nvm from git to '/root/.nvm'=> Cloning into '/root/.nvm'...
remote: Enumerating objects:278, done.
remote: Counting objects:100%(278/278), done.
remote: Compressing objects:100%(249/249), done.
remote: Total 278(delta 33), reused 88(delta 16), pack-reused 0
Receiving objects:100%(278/278),142.36 KiB |132.00 KiB/s, done.
Resolving deltas:100%(33/33), done.=> Compressing and cleaning up git repository
=> Appending nvm source string to /root/.bashrc
=> Appending bash_completion source string to /root/.bashrc
=> Close and reopen your terminal to start using nvm or run the following to use it now:export NVM_DIR="$HOME/.nvm"[-s "$NVM_DIR/nvm.sh"]&& \."$NVM_DIR/nvm.sh" # This loads nvm
[- s "$NVM_DIR/bash_completion"]&& \."$NVM_DIR/bash_completion" # This loads nvm bash_completion
[ root@server01 ~]#
According to the prompt, you can see that the script has added the contents of the relevant environment variables to the /root/.bashrc
file, let's take a look, as follows:
Set the environment variables to take effect
[ root@server01 ~]# source /root/.bashrc
[ root@server01 ~]# nvm -v
Node Version Manager
Note:<version> refers to any version-like string nvm understands. This includes:- full or partial version numbers, starting with an optional "v"(0.10, v0.1.2, v1)-default(built-in) aliases: node, stable, unstable, iojs, system
- custom aliases you define with`nvm alias foo`
Any options that produce colorized output should respect the `--no-colors` option.
Because the higher version of GitBook
has the problem that the html in the sidebar cannot be redirected, it is necessary to install a lower version of nodejs to be compatible.
Execute nvm install 6.16.0
to install, execute nvm use 6.16.0
to switch to the version of nodejs.
Of course, you can also install other versions for switching.
[ root@server01 ~]# nvm install 6.16.0
Downloading and installing node v6.16.0...
Downloading https://nodejs.org/dist/v6.16.0/node-v6.16.0-linux-x64.tar.xz...
######################################################################## 100.0 %
Computing checksum with sha256sum
Checksums matched!
Now using node v6.16.0(npm v3.10.10)
Creating default alias:default->6.16.0(-> v6.16.0)[root@server01 ~]#
[ root@server01 ~]# nvm use 6.16.0
Now using node v6.16.0(npm v3.10.10)[root@server01 ~]#
[ root@server01 ~]# npm -v
3.10.10[ root@server01 ~]# node -v
v6.16.0[root@server01 ~]#
Execute npm install -g gitbook-cli
to install Gitbook as follows:
Create a new directory and upload the gitbook
written under windows, as follows:
[ root@server01 redis_book]# ls
Chapter1 Chapter2 Chapter3 Chapter4 README.md SUMMARY.md
[ root@server01 redis_book]#
Start the preview service of GitBook as follows:
Since the system cannot recognize the Chinese path, the system language must be configured.
References: [Centos 7 Chinese language pack installation and Chinese support] (https://links.jianshu.com/go?to=https%3A%2F%2Fwww.centos.bz%2F2017%2F09%2Fcentos-7%25e4%25b8%25ad%25e6%2596%2587%25e8%25af%25ad%25e8%25a8%2580%25e5%258c%2585%25e7%259a%2584%25e5%25ae%2589%25e8%25a3%2585%25e5%258f%258a%25e4%25b8%25ad%25e6%2596%2587%25e6%2594%25af%25e6%258c%2581%2F)
View current system language
[ root@server01 redis_book]# echo $LANG
en_US.UTF-8[root@server01 redis_book]#
Use locale to check if there is a Chinese font library
[ root@server01 redis_book]# locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=[root@server01 redis_book]#
It can be found that there is no Chinese font library.
Install Chinese font library
yum install kde-l10n-Chinese -y
yum reinstall glibc-common -y
Check the language pack again
Use locale -a
to view the following:
Modify the configuration file etc/locale.conf
[ root@server01 ~]# cat /etc/locale.conf
LANG="en_US.UTF-8"[root@server01 ~]#
[ root@server01 ~]# vim /etc/locale.conf
[ root@server01 ~]#
[ root@server01 ~]# cat /etc/locale.conf
LANG="zh_CN.UTF-8"[root@server01 ~]#
After setting, use source /etc/locale.conf to reload the variables
[ root@server01 ~]# source /etc/locale.conf
[ root@server01 ~]#
[ root@server01 ~]# locale
LANG=zh_CN.UTF-8
LC_CTYPE="zh_CN.UTF-8"
LC_NUMERIC="zh_CN.UTF-8"
LC_TIME="zh_CN.UTF-8"
LC_COLLATE="zh_CN.UTF-8"
LC_MONETARY="zh_CN.UTF-8"
LC_MESSAGES="zh_CN.UTF-8"
LC_PAPER="zh_CN.UTF-8"
LC_NAME="zh_CN.UTF-8"
LC_ADDRESS="zh_CN.UTF-8"
LC_TELEPHONE="zh_CN.UTF-8"
LC_MEASUREMENT="zh_CN.UTF-8"
LC_IDENTIFICATION="zh_CN.UTF-8"
LC_ALL=[root@server01 ~]#
Finally, even if the system language is English utf-8, as long as the file is compressed and uploaded through the zip package, it can be used, and it is not necessary to set the system language to Chinese.
There are two ways, as follows:
gitbook serve &``setsid gitbook serve
Either way.
Recommended Posts