IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    centos 安装ghost博客

    Vacuity发表于 2021-09-11 16:54:01
    love 0

    centos 安装ghost博客

    参考官方在ubuntu上安装的文档:
    How to install & setup Ghost on Ubuntu 16.04, 18.04 and 20.04

    创建用户并给权限

    1、创建用户vacuity:

    [root@VM-0-14-centos ~]# adduser vacuity
    

    2、赋予用户root权限
    首先确保文件 /etc/sudoers 中,这行代码未被注释。

    %wheel  ALL=(ALL)       ALL
    

    然后执行:

    [root@VM-0-14-centos ~]# usermod -g wheel vacuity
    

    更新yum

    [root@VM-0-14-centos ~]# yum update
    

    安装 NGINX

    [root@VM-0-14-centos ~]# yum install nginx
    

    安装mysql

    此处自行安装

    安装node

    [root@VM-0-14-centos ~]# yum install nodejs
    

    注意ghost官方关于node版本说明:Supported node versions for self-hosted installs of Ghost
    仅支持12.x和14.x,推荐14.x,其他版本均不支持.

    查看node版本:

    [root@VM-0-14-centos ~]# node --version
    

    我这边显示版本是
    v10.24.0
    因此需要升级

    升级node

    安装n

    [root@VM-0-14-centos ~]# npm install -g n
    

    安装指定版本

    [root@VM-0-14-centos ~]# n 14.17.5
    

    切换 nodejs 版本

    编辑bash_profile:

    [root@VM-0-14-centos ~]# vim ~/.bash_profile
    

    在末尾添加:

    export N_PREFIX=/usr/local  (node实际安装位置)
    export PATH=$N_PREFIX/bin:$PATH
    

    如果你用上文方法安装的话,node的实际安装位置应该为 /usr/local/bin

    执行 source 使修改生效

    [root@VM-0-14-centos ~]# source ~/.bash_profile
    

    这时候再查看 node -v 发现版本切换成功了

    安装 Ghost-CLI

    [root@VM-0-14-centos ~]# sudo npm install ghost-cli@latest -g
    

    安装 Ghost

    创建目录

    创建目录: sitename 可以改为你喜欢的任意名称(英文,此处我用的ghost)

    [root@VM-0-14-centos ~]# sudo mkdir -p /var/www/sitename
    

    设置目录(替换为你前面创建的用户名称,此处我的为vacuity):

    [root@VM-0-14-centos ~]# sudo chown <user>:<user> /var/www/sitename
    

    赋予权限:

    [root@VM-0-14-centos ~]# sudo chmod 775 /var/www/sitename
    

    切换到目录:

    [root@VM-0-14-centos ~]# cd /var/www/sitename
    

    运行安装程序

    切换用户为前面创建的用户

    [root@VM-0-14-centos ~]# su vacuity
    

    运行安装命令:

    [vacuity@VM-4-2-centos ghost]$ ghost install
    
    ┌──────────────────────────────────────────────────────────────────────────────┐│    The current Node.js version (10.24.0) has reached end-of-life status.     ││ Ghost-CLI will drop support for this Node.js version in an upcoming release, ││                     please update your Node.js version.                      ││                See https://ghost.org/docs/faq/node-versions/.                │└──────────────────────────────────────────────────────────────────────────────┘
    ✔ Checking system Node.js version - found v10.24.0
    ✔ Checking logged in user
    ✔ Checking current folder permissions
    System checks failed with message: 'Linux version is not Ubuntu 16, 18, or 20'
    Some features of Ghost-CLI may not work without additional configuration.
    For local installs we recommend using `ghost install local` instead.
    ? Continue anyway? (y/N)
    

    出现上面意思是官方的ghost默认只支持ununtu,而我们用的centos,这里直接输入y,代表继续

    经过一段时间之后:

    Enter your blog URL: (http://localhost:2368):
    

    此处我输入:https://vacuity.me

    接下里就是一堆输入确认,此处注意尽量不要用默认的设置,比如不要让他设置系统服务啥的,因为他是采用ununtu的命令行,跟centos的并不兼容,所以会失败,nginx与证书之类的也需要自己设置,然后结束也不用自动启动。

    手动启动:

    [vacuity@VM-4-2-centos ghost]$ ghost start
    

    接下来就是ng反向代理与https证书等的配置了。

    到这里就差不多结束了,如果有其他问题欢迎邮件咨询(点击网页最底部的Contact标签联系)



沪ICP备19023445号-2号
友情链接