在CentOS7.2上安裝Ghost

  1. 部署環境
    CentOS7.2 1核1Gnode

  2. 安裝g++編譯器mysql

    yum update -y
    yum list gcc-c++
    yum install gcc-c++.x86_64 -y
  3. 安裝Nodejs
    目前Node.js v4.2.0 LTS 已經成爲Ghost推薦版本nginx

    wget https://nodejs.org/download/release/v4.2.0/node-v4.2.0.tar.gz
    tar zxvf node-v4.2.0.tar.gz
    cd node-v4.2.0
    ./configure 
    make && make install

    編譯安裝大約15分鐘c++

  4. 安裝Nginxsql

    vi /etc/yum.repos.d/nginx.repo

    寫入如下內容數據庫

    [nginx] 
    name=nginx repo  
    baseurl=http://nginx.org/packages/centos/$releasever/$basearch/  
    gpgcheck=0  
    enabled=1

    安裝Nginxnpm

    yum install nginx -y

    運行Nginxcentos

    systemctl start nginx

    配置文件bash

    vi /etc/nginx/conf.d/ghost.conf

    寫入如下內容ide

    server {  
    listen 80;
    server_name example.com; #將 example.com 改成本身的域名
    
    location / {
      proxy_set_header   X-Real-IP $remote_addr;
      proxy_set_header   Host      $http_host;
      proxy_pass         http://127.0.0.1:2368;
    }
    }

    重啓Nginx

    systemctl restart nginx

    設置爲開機啓動

    systemctl enable nginx
  5. 安裝MariaDB

    sudo yum install mariadb-server -y
    sudo systemctl enable mariadb
    sudo systemctl start mariadb
    sudo mysql_secure_installation

    登陸MariaDB

    mysql -u root -p

    使用q來退出

    爲了不數據庫存放的中文是亂碼,咱們還須要設置Mysql的編碼

    vi /etc/my.cnf

    寫入如下內容

    [client]
    default-character-set=utf8  
    [mysql]
    default-character-set=utf8  
    [mysqld]
    character-set-server=utf8  
    collation-server=utf8_general_ci

    重啓MariaDB

    systemctl restart mariadb

    新建一個數據庫,用來存放Ghost博客的數據
    登陸數據庫 mysql -u root -p
    建立ghost數據庫 create database ghost;
    新建一個用戶ghost,密碼爲123456 grant all privileges on ghost.* to 'ghost'@'%' identified by '123456';
    讓權限生效 flush privileges;

  6. 安裝Ghost(Ghost v0.7.4 full (zh))

    mkdir /var/www && cd /var/www
    wget http://dl.ghostchina.com/Ghost-0.7.4-zh-full.zip
    unzip Ghost-0.7.4-zh-full.zip -d ghost
    cd ghost 
    cp config.example.js config.js

    配置文件vi config.js
    Ghost有產品模式、開發模式和測試模式等多種運行模式,這裏咱們須要在配置文件中找到production模式,以下圖所示
    圖片描述

    見證奇蹟的時刻(啓動Ghost)

    npm start --production

    圖片描述

  7. 讓 Ghost 一直運行
    參考Ghost中文社區的文章 http://docs.ghostchina.com/zh...

  8. 參考資料
    https://www.linode.com/docs/d...
    https://snowz.me/how-to-insta...
    http://www.loyalsoldier.me/de...
    http://docs.ghostchina.com/zh...

相關文章
相關標籤/搜索