CentOS7下安装Ghost1.22博客

CentOS7下安装Ghost1.22博客

Chost博客已经更新到了1.22版本,下面介绍一下如何在CentOS7中安装.
这里采用Ghost+Mysql+Nginx的方式。

  1. Mysql安装配置

    安装mysql

    rpm -ivh http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm 
    yum -y install mysql-server mysql
    systemctl start mysqld.service
    

    配置mysql

    mysql 
    mysql> create database ghost;
    mysql> grant all on ghost.* to 'ghost'@localhost identified by 'ghost';
    mysql> flush privileges;
    

    这时执行mysql -ughost -pghost,就可以以ghost用户,ghost密码登录管理ghost数据库.

  2. node安装

    安装node6

    curl -sL https://rpm.nodesource.com/setup_6.x | bash -  
    yum install nodejs
    

    验证

    node -v
    
  3. 安装ghost-cli

    安装ghost-cli

    npm i -g ghost-cli
    

    最好升级一下最新的ghost-cli

    yum install -y git

    配置加速

    npm config set registry https://registry.npm.taobao.org
    

    安装过程

    
    npm i -g ghost-cli to update
    
  4. 配置ghost用户

    adduser ghost
    mkdir /var/www/ghost
    chown ghost /var/www/ghost
    
  5. 配置sudo权限

    groupadd sudo
    chown -R ghost:sudo /home/ghost/
    chmod 775 /home/ghost/
    usermod -aG sudo ghost
    
  6. 切换用户安装

    su ghost
    cd /var/www/ghost
    ghost install local --db mysql
    

    根据提示输入相关信息,即可

    [ghost@ming ghost]$ ghost install local --db mysql
    ✔ 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 v1.22.3 > Installing dependencies > [3/5] Fetching packages...
    

    等待总是漫长...

    ? Enter your MySQL hostname: localhost
    ? Enter your MySQL username: ghost
    ? Enter your MySQL password: [hidden]
    ? Enter your Ghost database name: ghost
    ✔ Configuring Ghost
    ✔ Setting up instance
    ✔ Running database migrations
    ℹ 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
    You can access your blog at http://localhost:2368/
    
    Ghost uses direct mail by default
    To set up an alternative email method read our docs at https://docs.ghost.org/docs/mail-config
    
  7. 修改配置文件

    查看ghost

     ghost ls
    

    可以看到ghost现在是运行在开发模式development下,下面修改为生产模式

    ghost stop
    cp config.development.json config.production.json
    

    在配置文件里面修改url,改成你自己的域名即可

    
    vi config.production.json
    
    "url": "http://120.27.119.12/"
    
    ghost start即可
    
  8. nginx 反向代理

    安装nginx

    yum install -y nginx
    

    修改配置

    cd /etc/nginx/conf.d/
    vi ghost.conf
    
    server {  
    listen 80;
    server_name 120.27.119.12;
    
    location / {
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   Host      $http_host;
        proxy_pass         http://127.0.0.1:2368;
    }
    }
    

    启动nginx

    nginx
    

    大家可以访问关注我的个人博客 遂更记忆 www.suigengjiyi.com

你可能感兴趣的:(博客搭建,ghost)