Local Gitbook - taoualiw/My-Knowledge-Base GitHub Wiki
- Install Node.js(v4.0.0 and above is recommended), to find the directory where npm packages are installed:
$ npm root -g
/usr/local/lib/node_modules
- Run the following command to install gitbook with npm
$ npm install gitbook-cli -g
gitbook-cli is an utility to install and use multiple versions of GitBook on the same system. It will automatically install the required version of GitBook to build a book.
####1. Create a directory (my-directory) with a SUMMARY.md and README.md
$ gitbook init ./my-directory
####2. Build a static website from md directory run the following inside the directory
$ gitbook build
==> the links would not work because the browser can not deal with file:// links, so we need a virtual host
####3. Set local web server The most prevalently used on the web is called Apache HTTP Server, commonly referred to simply as Apache.
####4. Configure the gitbook as a local site
- Create a home for my new local site
$ mkdir ~/Sites/mySite
-
Put the notebook directory (my-directory) inside the local site folder
-
Uncomment the following line in the httpd.conf file
#Include /private/etc/apache2/extra/httpd-vhosts.conf
- Open the following files
/private/etc/apache2/extra/httpd-vhosts.conf
and inset the following code:
<VirtualHost *:80>
DocumentRoot "/Users/username/Sites/mySite/my-directory/_book"
ServerName local.mySite
# Set access permission
<Directory "/Users/username/Sites/mySite/my-directory/_book">
Require all granted
</Directory>
</VirtualHost>
- Open up /etc/hosts and modify the first line buy adding the new local server name
127.0.0.1 localhost local.mySite
- Restart Apache
$ sudo apachectl restart
####4- Browse http://local.mysite/