Ghost v0.74 搭建(二)

添加后台服务

依旧参考这篇教程,采用supervior这个工具,按照教程来失败了好几次,忘了在某篇帖子看到,安装时不要使用 apt-get supervior这个命令,最好使用pip install supervisor来安装supervior;安装成功后首先启动supervior服务,service supervisor start,然后为 Ghost 创建一个启动脚本。通常为 /etc/supervisor/conf.d/ghost.conf ,例如

[program:ghost]
command = node /yourpath/ghost/index.js
directory = /yourpath/ghost
user = root
autostart = true
autorestart = true
stdout_logfile = /var/log/supervisor/ghost.log
stderr_logfile = /var/log/supervisor/ghost_err.log
environment = NODE_ENV="production"

然后root权限执行echo_supervisord_conf > /etc/supervisord.conf创建supervisord的配置文件,并将最后两行前面的注释符“#”去掉,改为

[include]
files = /etc/supervisor/conf.d/*.conf

执行命令更新配置文件:

sudo supervisorctl reload
sudo supervisorctl update

如果执行时报错:
No such file or directory: file: /usr/lib/python2.7/socket.py line: 224
可先执行如下命令

sudo supervisord -c /etc/supervisord.conf  
sudo supervisorctl -c /etc/supervisord.conf  

之后执行命令supervisorctl start ghost 启动ghost服务

如遇到问题最好参考一下官网的文档

comments powered by Disqus
京ICP备16019137号-1