2019独角兽企业重金招聘Python工程师标准>>>
0-安装环境
[lsug@172-16-1-105 ~]$ uname -a
Linux 172-16-1-105 2.6.32-573.el6.x86_64 #1 SMP Thu Jul 23 15:44:03 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
[lsug@172-16-1-105 ~]$ cat /etc/redhat-release
CentOS release 6.7 (Final)
1-安装gitbook需要的环境
- 安装git
- 安装nvm,node.js和NPM
- 升级python版本到2.7.1以上
- 安装gitbook及calibre组件(由于GitBook生成多格式的文件需要用到calibre,calibre最新版要求Python ≥ 2.7.1 not 3.x )
1.1安装git
安装依赖包
yum install gettext-devel openssl-devel perl-CPAN perl-devel zlib-devel
下载git版本
wget https://github.com/git/git/archive/v2.11.0.tar.gz
解压编译安装
tar -zxf git-2.11.0.tar.gz
cd git-2.11.0
autoconf
mkdir /data/git -p
./configure --prefix=/data/git/
make && make install
将git加入环境变量中
vim /etc/profile
export GIT_HOME=/data/git/
export PATH=$PATH:$GIT_HOME/bin
是修改生效
source /etc/profile
测试是否安装成功
[root@minion git-2.11.0]# git --version
git version 2.11.0
1.2-安装node.js和npm
安装node.js 6.1.0版本,自带npm3.10.10
[lsug@minion node-6.9.4]$ node -v
v6.9.4
[root@minion lsug]# npm -V
[email protected] /usr/local/lib/node_modules/npm
1.3 python从2.6.6升级到2.7.3
下载源码包
wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz
解压编译安装
tar -zxf Python-2.7.3.tgz
cd Python-2.7.3
mkdir -p /data/python2.7.3 -p
./configure --prefix=/data/python2.7.3
make
sudo make install
此时没有覆盖老版本,将老版本/usr/bin/python链接改为别的名字
sudo mv /usr/bin/python /usr/bin/python2.6.6
建立新版本python的连接
sudo ln -s /data/python2.7.3/bin/python2.7 /usr/bin/python
检查版本是否是2.7.3
[lsug@minion python-2.7.3]$ python
Python 2.7.3 (default, Jan 7 2017, 14:50:00)
[GCC 6.1.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
1.4 安装calibre
sudo 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('/data')"
命令的最后 main('/打他')
中/data
为Calibre的安装目录,可根据需要修改。
2.安装gitbook
[root@minion ~]# npm install -ggitbook
[lsug@minion ~]$ npm install -g gitbook-cli
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
/usr/local/lib
└─┬ [email protected]
├── [email protected]
├─┬ [email protected]
│ └── [email protected]
├─┬ [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
....................省略....
3-检查是否安装
[root@minion lsug]# gitbook -V
CLI version: 2.3.0
Installing GitBook 3.2.2
[email protected] ../../tmp/tmp-11827qTPkl0w2fFNl/node_modules/gitbook
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
....................省略....