在CentOS7.2上安装Ghost

前端之家收集整理的这篇文章主要介绍了在CentOS7.2上安装Ghost前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
  1. 部署环境
    CentOS7.2 1核1G

  2. 安装g++编译器

    1. yum update -y
    2. yum list gcc-c++
    3. yum install gcc-c++.x86_64 -y
  3. 安装Nodejs
    目前Node.js v4.2.0 LTS 已经成为Ghost推荐版本

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

    编译安装大约15分钟

  4. 安装Nginx

    1. vi /etc/yum.repos.d/Nginx.repo

    写入以下内容

    1. [Nginx]
    2. name=Nginx repo
    3. baseurl=http://Nginx.org/packages/centos/$releasever/$basearch/
    4. gpgcheck=0
    5. enabled=1

    安装Nginx

    1. yum install Nginx -y

    运行Nginx

    1. systemctl start Nginx

    配置文件

    1. vi /etc/Nginx/conf.d/ghost.conf

    写入以下内容

    1. server {
    2. listen 80;
    3. server_name example.com; #将 example.com 改为自己的域名
    4.  
    5. location / {
    6. proxy_set_header X-Real-IP $remote_addr;
    7. proxy_set_header Host $http_host;
    8. proxy_pass http://127.0.0.1:2368;
    9. }
    10. }

    重启Nginx

    1. systemctl restart Nginx

    设置为开机启动

    1. systemctl enable Nginx
  5. 安装MariaDB

    1. sudo yum install mariadb-server -y
    2. sudo systemctl enable mariadb
    3. sudo systemctl start mariadb
    4. sudo MysqL_secure_installation

    登录MariaDB

    1. MysqL -u root -p

    使用q退出

    为了避免数据库存放的中文是乱码,我们还需要设置MysqL的编码

    1. vi /etc/my.cnf

    写入以下内容

    1. [client]
    2. default-character-set=utf8
    3. [MysqL]
    4. default-character-set=utf8
    5. [MysqLd]
    6. character-set-server=utf8
    7. collation-server=utf8_general_ci

    重启MariaDB

    1. 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))

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

    配置文件vi config.js
    Ghost有产品模式、开发模式和测试模式等多种运行模式,这里我们需要在配置文件中找到production模式,如下图所示

    见证奇迹的时刻(启动Ghost)

    1. 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...

猜你在找的CentOS相关文章