美文网首页
Centos7.3搭建Ghost博客

Centos7.3搭建Ghost博客

作者: 伊人半笑 | 来源:发表于2017-07-26 22:56 被阅读82次

一、nvm安装

1、nvm
没有wget先安装

image.png

根据=>提示,.bashrc文件已经有以下三行命令,直接运行这三行命令

image.png

安装成功


image.png

二、安装nodejs

查看所有版本


image.png

查看长久支持的版本

image.png

根据官方介绍安装合适版本,这里选择4.2.0版本


$ nvm install 4.2.0

三、安装nginx

//安装
$ yum install nginx -y
//启动
$ systemctl start nginx
//设置开机启动
$ systemctl enable nginx

防火墙配置

查看正在监听的端口,80端口已开启

image.png

查看防火墙默认Zone

image.png
//开放80端口
$ firewall-cmd --permanent --zone=public --add-port=80/tcp
//查看所有开放的端口,80端口已开放
$ firewall-cmd --permanent --list-port

浏览器访问linux主机ip

image.png

配置Nginx

$ cd /etc/nginx/conf.d/
//该目录下创建ghost.conf
$ vim ghost.conf
//粘贴以下代码
server {
        listen 80;
        server_name 192.168.1.21; # 服务器Ip地址
        location / {
                proxy_set_header  X-Real-IP $remote_addr;
                proxy_set_header  Host      $http_host;
                proxy_pass        http://127.0.0.1:2368;
        }
}
//保存
$ :wq
//重启Nginx
$ systemctl restart nginx

四、安装MySQL

ghost默认使用sqlite数据库,也可使用MySQL数据库

//CentOS7 yum中没有MySQL,先下载repo源
$ wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
//安装rpm包
$ rpm -ivh mysql-community-release-el7-5.noarch.rpm
//安装MySQL
$ yum install mysql-server

配置MySQL

//启动MySQL
$ systemctl start mysqld
//设置开机启动
$ systemctl enable mysqld
//使用命令mysql_secure_installation对mysql进行安全配置
$ mysql_secure_installation

Set root password? [Y/n] #设置root密码  
anonymous users? [Y/n] #删除匿名用户  
Disallow root login remotely? [Y/n] #禁止root用户远程登录  
Remove test database and access to it? [Y/n] #删除默认的 test 数据库  
Reload privilege tables now? [Y/n] #刷新授权表使修改生效  

避免数据库存放的中文乱码,需要设置编码,执行命令vim /etc/my.cnf
粘贴以下内容

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

重启MySQL

systemctl restart mysqld

创建ghost数据库并配置

$ mysql -u root -p # 输入设置好的密码 
$ create database ghost; # 创建ghost数据库 
$ grant all privileges on ghost.* to 'ghost'@'%' identified by '123456'; # 新建一个用户ghost,密码为123456,这里自己设置 
$ flush privileges; # 重新读取权限表中的数据到内存,不用重启mysql就可以让权限生效 

五、下载Ghost

//var目录下创建www
$ cd /var/www
//下载
$ wegt http://dl.ghostchina.com/Ghost-0.7.4-zh-full.zip
//解压
$ unzip Ghost-0.7.4-zh-full.zip -d ghost
//进入ghost
$ cd ghost
//修改配置
$ cp config.example.js config.js 
$ vim config.js
image.png

运行

$ npm start --production

如果出现504错误页面,检查selinux是否开启

$ sestatus
//禁用selinux
$ vim /etc/selinux/config
//修改为
SELINUX=disabled
//重启
init 6

六、运行

安装pm2

$ cd /var/www/ghost
$ npm install pm2 -g
$ NODE_ENV=production pm2 start index.js --name "ghost"  #生产模式启动
$ pm2 startup centos #开机启动
$ pm2 save

参考学习:
Ghost 博客搭建日记

相关文章

  • Centos7.3搭建Ghost博客

    一、nvm安装 1、nvm没有wget先安装 根据=>提示,.bashrc文件已经有以下三行命令,直接运行这三行命...

  • 搭建ghost博客

    采用vps+mysql+nodejs+nginx+ghost的组合方式 系统采用 centos6.5 x64 my...

  • 搭建ghost博客

    最近突然想自己搭建一个博客,网上搜了几个自己搭建博客的方法,最后还是选择了ghost。 以下是搭建步骤(此处是搭建...

  • GHOST 博客搭建

    安装 推荐使用brew来安装,linux用户可以下载linuxbrew,比系统自带的管理软件管理起来更方便,可以随...

  • Ghost - 博客搭建

    文章参考自 kitten 的这篇文章和 Ghost 官网王赛写的这篇文章那么既然已经有人写了很详细的文章,为什么我...

  • 我的新博客

    最近新鼓捣了一个新的个人博客,使用Ghost 博客框架搭建.非常棒! 博客搭建过程 使用Docker 搭建Ghos...

  • 1. 使用 GHOST-CLI 在本地搭建 ghost 开发环境

    安装环境 Ghost v1 推出了 GHOST-CLI ,使得搭建 ghost 博客更加方便了。该系列教程将在 w...

  • 160Ghost 3 搭建个人博客网站

    实验介绍 Ghost 是著名的开源博客系统。如果你是零基础人士,且想要搭建一个自己的博客,那么 Ghost 一定是...

  • 搭建Ghost博客系统

    写在前面的话 很早就想搞个博客,最近有朋友跟我安利使用GHOST博客来创建个人博客。本周末正好有空,就开始动手整了...

  • 【Ghost】搭建个人博客

    前言 最近脑子一抽,想用ghost搭建一个博客。本来以为,直接把东西往服务器上一扔就行了。没想到还要搞什么Linu...

网友评论

      本文标题:Centos7.3搭建Ghost博客

      本文链接:https://www.haomeiwen.com/subject/fpzmkxtx.html