centos 安装 ghost3.0

ghost Mar 18, 2020

Ghost是一个基于Node.js的开源专业发布平台。

服务器要求

  • NGINX (minimum of 1.9.5 for SSL)
  • Node.js (10.x)
  • MySQL 5.5, 5.6, or 5.7 (not >= 8.0)
  • Systemd
  • 1G 内存
  • 已注册的域名

服务器设置

创建一个新用户

# 以 root用户登录服务器
ssh root@your_server_ip

# 创建新用户
adduser <user>

# 为新用户添加sudo权限
usermod -aG sudo <user>

# 以新用户登录
su - <user>

更新所有包、软件

# 更新所有包、软件和系统内核
sudo yum -y update

安装 Nginx

# 安装Nginx
sudo yum -y install nginx

# 启动Nginx
service nginx start

安装 MySQL

# 下载MySQL的rpm源   
curl -LO http://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm  
# 安装 mysql 源  
sudo yum localinstall mysql57-community-release-el7-11.noarch.rpm   
# 检查 yum 源是否安装成功   
sudo yum repolist enabled | grep "mysql.*-community.*"   
# 安装MySQL Server   
sudo yum install mysql-community-server  

# 安装MySQL服务   
sudo systemctl enable mysqld  
# 启动MySQL服务  
sudo systemctl start mysqld   
# 查看服务状态  
sudo systemctl status mysqld 

修改 root 默认密码

# 查找默认密码
grep 'temporary password' /var/log/mysqld.log  

# 登陆MySQL,修改密码
mysql -u root -p
ALTER USER 'root'@'localhost' IDENTIFIED BY 'newpassword';

安装Node.js

# 添加Node 8的rpm源  
curl --silent --location https://rpm.nodesource.com/setup_10.x | sudo bash -   
# 安装Node.js  
sudo yum -y install nodejs  

安装 Ghost-CLI

# 安装Ghost-CLI  
sudo npm install ghost-cli@latest -g

安装 Ghost

创建目录及用户赋权限

# 创建目录
sudo mkdir -p /home/blog_fujinliang

# 将目录的所有者改为之前创建的新用户
sudo chown <user>:<user> /home/blog_fujinliang

# 修改目录的访问权限
sudo chmod 775 /home/blog_fujinliang

# 进入目录
cd /home/blog_fujinliang

安装 ghost

ghost install

运行效果如下:

? Enter your blog URL: http://www.fujinliang.top
? Enter your MySQL hostname: localhost
? Enter your MySQL username: root
? Enter your MySQL password (skip to keep current password): [hidden]
? Enter your Ghost database name: blog_fujinliang_prod
✔ Configuring Ghost
+ sudo chown -R ghost:ghost /home/blog_fujinliang/content
✔ Setting up "ghost" system user
? Do you wish to set up "ghost" mysql user? No
ℹ Setting up "ghost" mysql user [skipped]
Nginx is not installed. Skipping Nginx setup.
ℹ Setting up Nginx [skipped]
Nginx setup task was skipped, skipping SSL setup
ℹ Setting up SSL [skipped]
Systemd service has already been set up. Skipping Systemd setup
ℹ Setting up Systemd [skipped]
+ sudo systemctl is-active ghost_www-fujinliang-top
✖ Starting Ghost
One or more errors occurred.
1) ProcessError

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

unknown

Exit code: 3


Debug Information:
    OS: CentOS Linux, v7
    Node Version: v10.19.0
    Ghost Version: 3.11.0
    Ghost-CLI Version: 1.13.1
    Environment: production
    Command: 'ghost setup'

出现错误

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

解决方法:

sudo systemctl start  ghost_www-fujinliang-top

ghost start

配置nginx

server
    {
        listen 80;
        #listen [::]:80 default_server ipv6only=on;
        server_name fujinliang.top www.fujinliang.top;

        location / {
            proxy_pass http://127.0.0.1:2368;
        } 

        access_log  off;
    }

重启nginx

sudo service nginx start
恭喜! 你已经成功订阅了.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.