Ghost博客升级

最近看到期待已久的ghost已经支持 Android Client
赶紧在拿出手机下载安装上,找了下只有 Google Play 有得下载,于是先下载安装了 Google Play ,装完登陆发现这货只支持 Ghost v1.x 的版本,v1.x 以下的抱歉不可用,想想自己的博客用的版本也有点年纪了,目前服务端版本也都更新到 Ghost v1.23.0 了,然而我的博客版本还是用着好几年的 v0.74 的版本,好像也是目前的唯一中文版,于是就索性给博客升级下 升级之路有点坑,折腾了一天,总算完美升级了,做个小记录,得瑟得瑟 啧啧啧!

系统环境:

  • node v6.12.1
  • nginx 1.14.0
  • mysql 5.6
  • Ghost-CLI version: 1.7.3
  • Ghost Version : 1.23.0

  • 先备份之前的博客,后台有个导出博客数据的功能,挺好用,不用去折腾数据库了
  • images 和 Themes,这个后台没有,只能在服务器上将ghost对应的目录打包备份
  • 新版的 ghost 引入了 ghost-cli ,管理更加方便了

安装 Node

以前总是傻乎乎的去下源码包编译,原来node早支持yum安装了

[root@MyFirstwon ~]# curl -sL https://rpm.nodesource.com/setup_6.x | bash
[root@MyFirstwon ~]# yum -y install nodejs
... ...
[root@MyFirstwon ~]# node -v
v6.12.1
[root@MyFirstwon ~]# 

安装 Mysql

[root@MyFirstwon ~]# wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
[root@MyFirstwon ~]# rpm -ivh  mysql-community-release-el7-5.noarch.rpm
[root@MyFirstwon ~]# ll /etc/yum.repos.d/mysql-community*
-rw-r--r-- 1 root root 1209 1月  29 2014 /etc/yum.repos.d/mysql-community.repo
-rw-r--r-- 1 root root 1060 1月  29 2014 /etc/yum.repos.d/mysql-community-source.repo
[root@MyFirstwon ~]#


[root@MyFirstwon ~]# cat /etc/yum.repos.d/mysql-community.repo 
[mysql-connectors-community]
name=MySQL Connectors Community
baseurl=http://repo.mysql.com/yum/mysql-connectors-community/el/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

[mysql-tools-community]
name=MySQL Tools Community
baseurl=http://repo.mysql.com/yum/mysql-tools-community/el/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

# Enable to use MySQL 5.5
[mysql55-community]
name=MySQL 5.5 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.5-community/el/7/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

# Enable to use MySQL 5.6   默认是5.6的
[mysql56-community]
name=MySQL 5.6 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

# Note: MySQL 5.7 is currently in development. For use at your own risk.
# Please read with sub pages: https://dev.mysql.com/doc/relnotes/mysql/5.7/en/
[mysql57-community-dmr]
name=MySQL 5.7 Community Server Development Milestone Release
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

[root@MyFirstwon ~]# yum -y install mysql-community-server
... ...

安装 Nginx

cat >>/etc/yum.repos.d/nginx.repo<< Nginx
> [nginx]
> name=nginx repo
> baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
> gpgcheck=0
> enabled=1
> Nginx


[root@MyFirstwon ~]# cat /etc/yum.repos.d/nginx.repo 
[nginx] 
name=nginx repo  
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/  
gpgcheck=0  
enabled=1 
[root@MyFirstwon ~]# 
[root@MyFirstwon ~]# yum -y install nginx
... ...
[root@MyFirstwon ~]# nginx -v
nginx version: nginx/1.14.0
[root@MyFirstwon ~]# 
[root@MyFirstwon ~]# cat /etc/nginx/conf.d/ghost.conf 
server {
    listen 80;
    server_name myfirstwon.com; # 将 myfirstwon.com 改为你的域名或ip。
    location / {
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   Host      $http_host;
        proxy_pass         http://127.0.0.1:2368;
    }
}
[root@MyFirstwon ~]# systemctl start nginx 
[root@MyFirstwon ~]# systemctl enable nginx

安装完node后,就可以使用npm安装 ghost 管理工具 ghost-cli

[root@MyFirstwon www]# npm g -i install ghost-cli 
[root@MyFirstwon www]# ghost -v
Ghost-CLI version: 1.7.3
[root@MyFirstwon www]# mkdir /var/www/ghost
[root@MyFirstwon www]# cd /var/www/ghost
[root@MyFirstwon ghost]# useradd ghost
[root@MyFirstwon ghost]# chown -R ghost:ghost /var/www/ghost

新版本的 ghost 安全性提高了很多,不能用root安装

[root@MyFirstwon ghost]# ghost install local --db=mysql
You can't run commands as the 'root' user.
Switch to your regular user, or create a new user with regular account privileges and use this user to run 'ghost install'.
For more information, see https://docs.ghost.org/install/ubuntu/#create-a-new-user-.

[root@MyFirstwon ghost]#
[root@MyFirstwon ghost]# su ghost
[ghost@MyFirstwon ghost]# ghost install local  --db=mysql 

2019-06-22 我又更新了版本

步骤和上面的一样,版本升了而已(包括系统,哈哈哈)
目前环境如下:

  • Centos 7.6
  • Mysql 5.6
  • Nginx 1.16.0
  • Node v8.16.0
  • Ghost-CLI version: 1.11.0
  • Ghost 1.25.1

新版本的界面好看太多了,

comments powered by Disqus