Centos7 安装Ghost 新入的坑

测试环境

  • 阿里云 Centos7.4 x64

安装宝塔面板

//登录服务器
# ssh root@192.168.1.1

//安装宝塔
# yum install -y wget && wget -O install.sh http://download.bt.cn/install/install.sh && sh install.sh

安装 Node.js

# yum install -y nodejs

不过在安装之前你得需要查看Node.js版本是否符合官方的版本(V6):

# yum info nodejs

我的返回结果:

Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Available Packages
Name        : nodejs
Arch        : x86_64
Epoch       : 1
Version     : 6.11.3
Release     : 1.el7
Size        : 4.6 M
Repo        : epel/7/x86_64
Summary     : JavaScript runtime
URL         : http://nodejs.org/
License     : MIT and ASL 2.0 and ISC and BSD
Description : Node.js is a platform built on Chrome's JavaScript runtime
            : for easily building fast, scalable network applications.
            : Node.js uses an event-driven, non-blocking I/O model that
            : makes it lightweight and efficient, perfect for data-intensive
            : real-time applications that run across distributed devices.

看到其中的Version : 6.11.3 符合条件就行了。否则你需要按照下面的步骤来做。

官方文档说的是载入Node.js源

# curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash 

然后刷新源安装Node.js:

# yum update
# yum install -y nodejs

这样Node.js环境安装好了。

替换国内npm环境

阿里云香港可跳过此步,不然会适得其反。

//打开配置文件
# vi ~/.npmrc

//写入配置文件
# registry =https://registry.npm.taobao.org

安装 Ghost-cli

安装Ghost脚手架:

# npm i -g ghost-cli

添加新用户

# adduser doocii && passwd doocii

doocii 为用户名,然后需要输入两次密码,编辑sudo配置文件,并给与新用户正确的权限:

# visudo 

示例(给予新用户root权限):

#Allow root to run any commands anywhere
root    ALL=(ALL)       ALL
doocii    ALL=(ALL)       ALL

保存退出,重启SSH:

# service sshd restart

切换用户

# su doocii

安装博客程序

$ cd /data/wwwroot/test.com  
// 提前将test.com文件夹权限更改为777

$ ghost install

配置Nginx

登录宝塔面板进入【网站】-> 选择test.com -> 【配置文件】清空所有配置,重写为

server {  
    listen 80;
    server_name test.com;  //你的博客域名
    location / {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $http_host;
        proxy_pass http://127.0.0.1:2368;
    }
}

启动报错

[doocii@iZj6cg86axadntslwisj38Z blog.doocii.com]$ ghost start
Running sudo command: systemctl is-active ghost_localhost
A ProcessError occurred.

Message: Command failed: /bin/sh -c sudo -S -p '#node-sudo-passwd#'  systemctl is-active ghost_localhost

unknown

Exit code: 3


Debug Information:
    OS: CentOS, v7.4.1708
    Node Version: v6.14.2
    Ghost-CLI Version: 1.8.1
    Environment: production
    Command: 'ghost start'

Additional log info available in: /home/doocii/.ghost/logs/ghost-cli-debug-2018-06-08T15_16_40_614Z.log

Try running ghost doctor to check your system for known issues.

Please refer to https://docs.ghost.org/v1/docs/troubleshooting#section-cli-errors for troubleshooting.

解决方法:

不知怎的,我自己解决了这个问题。

# sudo systemctl start ghost_localhost
# ghost start

参考

Centos7 安装Ghost 新入的坑
Share this