Install GitBook on your own server, and install gitbook on the server

Source: Internet
Author: User

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:pythonTo 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/optThe 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.mdAndSUMMARY.mdTwo files

Generate HTML and other format files

1. Generate complete static HTML: Switch to the book directory.builtYou can.

$ cd /home/gitbook/demo/$ gitbook build

The/home/gitbook/demo/Directory generation_bookDirectory, 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.CalibreGitbook 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 QStyleAndImportError: cannot import name QImageIt 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/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.