Install GitBook on your own server, and install gitbook on the server
You accidentally found that the open-source EBook production software GitBook, you can configure relevant information on the official website and bind it with your GitHub account to create your own EBook, download is supported in PDF, ePub, and MOBI formats.
But I want to install GitBook to generate the HTML format, so that I can put it in my own website.
Installation Process:
- Install the Basic Environment
- Install Git
- Install NVM, Node. js, and NPM
- Upgrade Python to 2.7.1 or later.
- Install GitBook and calibre Components
- Initialize and generate Demo
- Generate HTML and other format files
Install Git in the Basic Environment
I wrote the CentOS Installation Process on my Q & A website. Click CentOS to install Git.
Install NVM, Node. js, and NPM
Quickly build a Node. js/io. js development environment and accelerate npm
Upgrade Python to 2.7.1 or later.
Because calibre is required to generate multi-format files in GitBook, the latest version of calibre requires python ≥2.7.1 not 3.x.
View the Python version:python
To check whether the Python version meets the requirements.
To upgrade Python, see centos python 2.7.3.
Install GitBook and calibre Components
Install GitBook:
$ npm install gitbook-cli -g
Install calibre:
Calibre installation documentation For Linux
The installation code I found is as follows:
wget -nv -O- https://raw.githubusercontent.com/kovidgoyal/calibre/master/setup/linux-installer.py | python -c "import sys; main=lambda x:sys.stderr.write('Download failed\n'); exec(sys.stdin.read()); main('/opt')"
Command endmain('/opt')
Medium/opt
The installation directory of Calibre, which can be modified as needed.
Initialize and generate Demo
$ cd /home/$ mkdir gitbook$ cd gitbook/$ mkdir demo$ cd demo/$ gitbook init
After the last command is executed/home/gitbook/demo/
GenerateREADME.md
AndSUMMARY.md
Two files
Generate HTML and other format files
1. Generate complete static HTML: Switch to the book directory.built
You can.
$ cd /home/gitbook/demo/$ gitbook build
The/home/gitbook/demo/
Directory generation_book
Directory, which is a complete HTML static website
2. Generate files in other formats
Switch to the project directory first: for example, the local/home/gitbook/
PDF:
gitbook pdf ./demo ./demo.pdf
EPub:
gitbook epub ./demo ./demo.epub
MOBI:
gitbook mobi ./demo ./demo.mobi
Note: installation is required in advance.Calibre
Gitbook uses the ebook-convert component to convert the book format.
Bug I encountered
Since I have not learned node. js and PythonInstall calibreAn error occurred in that step, causing problems when GitBook generates other format files,Generating pdf and mobi will fail, but epub will succeed..
Error message when installing calibre:
Failed to find directory to install bash completions, using default.____________________ WARNING ____________________Setting up completion failed with error:__________________________________________________ Traceback (most recent call last): File "site-packages/calibre/linux.py", line 748, in setup_completion File "site-packages/calibre/linux.py", line 505, in write_completion File "site-packages/calibre/gui2/__init__.py", line 8, in <module> ImportError: cannot import name QStyleSetting up desktop integration...____________________ WARNING ____________________Setting up desktop integration failed with error:__________________________________________________ Traceback (most recent call last): File "site-packages/calibre/linux.py", line 781, in setup_desktop_integration File "site-packages/calibre/linux.py", line 1097, in render_img ImportError: cannot import name QImageCreating un-installer: /usr/bin/calibre-uninstallThere were 2 warnings* Setting up completion failed with error:* Setting up desktop integration failed with error:Run "calibre" to start calibre
SlaveImportError: cannot import name QStyle
AndImportError: cannot import name QImage
It is estimated that the Python library is missing and you may want to solve this problem.
Reference
Http://faq.devwiki.cn/
Https://github.com/GitbookIO/gitbook
Http://www.calibre-ebook.com/download_linux
Https://github.com/GitbookIO/gitbook
Http://blog.liyibo.org/books-installation-authoring-tool-gitbook/