欢迎光临
我一直在努力开车

【教程】centos7下搭建gitbook并设置开机自启

Abbey在迁移PyOne文档,因为使用的是gitbook,因此需要提前安装nodejs….为了避免下次又去搜索安装教程,不如将自己折腾的过程记录一下

安装nodejs

wget https://nodejs.org/dist/v9.9.0/node-v9.9.0.tar.gz
tar zxvf node-v9.9.0.tar.gz 
cd node-v9.9.0
./configure 
make #此处可能等待时间会比较长
make install

安装完看一下nodejs的版本:

node -v

安装gitbook

安装完nodejs,接着继续安装gitbook

npm install gitbook-cli -g

运行gitbook

因为PyOne的文档都是现成的,而且已经在github建立了repo,所以这里直接clone下repo,然后运行

git clone https://github.com/abbeyokgo/PyOne-wiki.git
cd PyOne-wiki
gitbook serve

运行之后会提示:

[[email protected] PyOne-wiki]# gitbook serve
Installing GitBook 3.2.3
[email protected] ../../tmp/tmp-8472baZUkcR1V2ia/node_modules/gitbook
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected]
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected])
├── [email protected]
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected])
├── [email protected] ([email protected])
├── [email protected]
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
└── [email protected]
Live reload server started on port: 35729
Press CTRL+C to quit ...
info: 7 plugins are installed 
info: loading plugin "livereload"... OK 
info: loading plugin "highlight"... OK 
info: loading plugin "search"... OK 
info: loading plugin "lunr"... OK 
info: loading plugin "sharing"... OK 
info: loading plugin "fontsettings"... OK 
info: loading plugin "theme-default"... OK 
info: found 55 pages 
info: found 47 asset files 
info: >> generation finished with success in 8.1s ! 
Starting server ...
Serving book on http://localhost:4000

curl一下,看是否正常运行

curl 127.0.0.1:4000

绑定域名

需要注意的是:上面虽然运行了gitbook,但是还是需要绑定域名之后才能域名。

这里不做更多的累述,直接看wiki教程:https://wiki.pyone.me/pyone-an-zhuang/bang-ding-yu-ming.html

开机启动

gitbook的开机启动,这里使用supervisor

首先安装pip

wget https://bootstrap.pypa.io/get-pip.py && python get-pip.py

然后安装supervisor

pip install supervisor

然后在PyOne-wiki文件夹下创建一个supervisord.conf文件,注意文件夹是否正确

[unix_http_server]
file=/var/supervisor.sock
[supervisord]
logfile=/var/supervisord.log
logfile_maxbytes=50MB
logfile_backups=10
loglevel=info
pidfile=/var/supervisord.pid
nodaemon=false
minfds=1024
minprocs=200
[inet_http_server]         ; inet (TCP) server disabled by default
port=*:9001
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisorctl]
serverurl=unix:///var/supervisor.sock
[program:wiki]
command = gitbook serve
directory = /root/PyOne-wiki
autorestart = true

最后设置开机启动

cat 'supervisord -c /root/PyOne-wiki/supervisord.conf' >> /etc/rc.d/rc.local
chmod +x /etc/rc.d/rc.local

然后重启就可以啦!

 

赞(0)
未经允许不得转载:一个人的公交 » 【教程】centos7下搭建gitbook并设置开机自启

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

Onedrive个人网盘搭建

GitHub地址联系Abbey