Ghost簡(jiǎn)介
Ghost 是基于 Node.js 構(gòu)建的開(kāi)源博客平臺(tái),由前 WordPress UI 部門(mén)主管 John O’Nolan 和 WordPress 高級(jí)工程師(女) Hannah Wolfe 創(chuàng)立。Ghost 具有易用的書(shū)寫(xiě)界面和體驗(yàn),博客內(nèi)容默認(rèn)采用Markdown 語(yǔ)法書(shū)寫(xiě)。Ghost 的目標(biāo)是取代臃腫的 WordPress。目的是為了給用戶(hù)提供一種更加純粹的內(nèi)容寫(xiě)作與發(fā)布平臺(tái)。
開(kāi)始搭建Ghost博客系統(tǒng)
1、本機(jī)測(cè)試環(huán)境
[linuxidc@localhost ~]$ cat /etc/RedHat-release
CentOS Linux release 7.5.1804 (Core)
[linuxidc@localhost ~]$ uname -r
3.10.0-862.el7.x86_64
2、 安裝Node.js
#更新yum源
[root@mingc ~]# sudo yum update -y
#安裝軟件組包Development Tools
[linuxidc@localhost ~]$ sudo yum groupinstall -y “Development Tools”
#安裝NodeSource Node.js 6.x repo
[root@localhost ~]# curl –silent –location https://rpm.nodesource.com/setup_6.x | bash –
#yum安裝 nodejs
[root@localhost ~]# yum -y install nodejs
#npm國(guó)內(nèi)鏡像(npm是隨同NodeJS一起安裝的包管理工具)
[root@localhost ~]# npm config set registry https://registry.npm.taobao.org
#安裝cnpm模塊(因?yàn)閲?guó)內(nèi)網(wǎng)絡(luò)的關(guān)系,也同時(shí)安裝了 cnpm 模塊,后續(xù)將使用該命令代替 npm 命令。)
[root@localhost ~]# npm i -g cnpm
#通過(guò)node -v 和npm -v命令查看是否安裝成功。
[root@localhost ~]# node -v
v6.14.4
[root@localhost ~]# npm -v
3.10.10
[root@localhost ~]#
3.、安裝 Ghost
①安裝 Ghost Client (ghost-cli)
[root@localhost ~]# cnpm i -g ghost-cli
#安裝成功后通過(guò)運(yùn)行 ghost -v,出現(xiàn)版本號(hào)即可表示安裝成功。
[root@localhost ~]# ghost -v
Ghost-CLI version: 1.9.6
[root@localhost ~]#
②添加 Ghost 運(yùn)行用戶(hù)并創(chuàng)建目錄
[root@localhost ~]# adduser ghost
[root@localhost ~]# mkdir /var/www
[root@localhost ~]# mkdir /var/www/ghost
[root@localhost ~]# chown ghost /var/www/ghost
③安裝SQLite3 數(shù)據(jù)庫(kù)
#新版本不允許root用戶(hù)安裝,需要切換普通用戶(hù)進(jìn)行安裝。
[root@localhost ~]# su – ghost
[ghost@localhost ~]$ cd /var/www/ghost
[ghost@localhost ghost]$ ghost install local –db=sqlite3
✔ Checking system Node.js version
✔ Checking current folder permissions
✔ Checking memory availability
✔ Checking for latest Ghost version
✔ Setting up install directory
✔ Downloading and installing Ghost v2.3.0
✔ Finishing install process
✔ Configuring Ghost
✔ Setting up instance
ℹ Ensuring user is not logged in as ghost user [skipped]
ℹ Checking if logged in user is directory owner [skipped]
✔ Checking current folder permissions
✔ Validating config
✔ Checking memory availability
✔ Starting Ghost
Ghost uses direct mail by default. To set up an alternative email method read our docs at https://ghost.org/mail
——————————————————————————
Ghost was installed successfully! To complete setup of your publication, visit:
http://localhost:2368/ghost/
④啟動(dòng) ghost
安裝成功后 Ghost 默認(rèn)就已經(jīng)啟動(dòng)的
# 停止host
[ghost@localhost ghost]$ ghost stop
✔ Stopping Ghost
# 啟動(dòng)ghost
[ghost@localhost ghost]$ ghost start
#重啟ghos
[ghost@localhost ghost]$ ghost restart
安裝成功后默認(rèn)是運(yùn)行在http://localhost:2368/
可使用如下方式訪問(wèn):
[ghost@localhost ghost]$ curl http://localhost:2368/
4. 安裝 Nginx和整合nodejs
[ghost@localhost ghost]$ su – root
[root@localhost ~]# yum install -y nginx
#啟動(dòng) Nginx
[root@localhost ~]# systemctl start nginx.service
#查看nginx是否運(yùn)行
[root@localhost ~]# ps -ef|grep nginx
#查看是否啟動(dòng)成功 http://你的ip
#設(shè)置開(kāi)機(jī)自啟動(dòng)
[root@localhost ~]# systemctl enable nginx.service
#整合nodejs
[root@localhost ~]# cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.ori
[root@mingc nginx]# vi /etc/nginx/nginx.conf +47
server {
···
location / {
proxy_pass http://127.0.0.1:2368;
proxy_redirect default;
root /usr/share/nginx/html;
index index.html index.htm;
}
···
[root@localhost ~]# nginx -s reload
5. 訪問(wèn)搭建的ghost博客
前臺(tái)頁(yè)面:http://你的ip/
host博客
后臺(tái)登錄頁(yè)面:http://你的ip/ghost
后臺(tái)管理頁(yè)面:
Ghost作為一個(gè)新興的博客系統(tǒng)肯定會(huì)有一些不足,但是我們相信它會(huì)越來(lái)越好的,希望大家都能用它來(lái)記錄生活中一些美好的時(shí)刻,分享自己的精彩的創(chuàng)意,共同建立并且維護(hù)這樣一個(gè)和諧的互聯(lián)網(wǎng)大家庭。
以上搭建過(guò)程本人親自操作可用,有問(wèn)題可留言評(píng)論。