Ghost博客安装
Ghost博客是一个基于Node.js 的开源博客平台,由前WordPress UI 部门主管John O’Nolan 和WordPress 高级工程师Hannah Wolfe 创立,目的是为了给用户提供一种更加纯粹的内容写作与发布平台。
目前来看,Ghost博客相对于Wordpress来说没有太明显的优势,现在的用户也都是码农们和喜欢尝鲜的朋友居多。当然Ghost博客体验良好的markdown编辑器、响应式前后台设计、采用的实时架构,让博客变得更有效率。
Ghost博客从2013年10月开始发布,现在已经更新了多个版本,各方面也逐渐完善起来了,但是普及率还有待于提高。Ghost需要Node.js环境和搭建难度过大,应该是Ghost博客推广的主要障碍。未来Ghost博客有很大的发展潜力。
安装Node运行环境Node.js是一个可以快速构建网络服务及应用的平台,基于Chromes JavaScript runtime,即Google V8引擎,是一款高性能的服务架构平台。
yum安装
yum install nodejs(适用于Centos等)
apt-get方式安装(适用于Ubutun等)
apt-get install nodejs
windows安装
直接下载安装包安装nodejs
命令行执行命令:node -v,可以查看是否成功安装Node.js,npm -v可以查看是否安装了npm。
如果没有安装npm,输入
yum install npm安装 Ghost
建议先阅读http://www.ghostchina.com/download/。
Ghost 中文集成版下载(建议下载此版本,包含组件sqlite等)
最新版本:Ghost v0.7.0 full (zh)
cd /www/ #中文集成版 wget http://dl.ghostchina.com/Ghost-0.7.0-zh-full.zip #中文标准版 #wget http://dl.ghostchina.com/Ghost-0.7.0-zh.zip mkdir ghost cd ghost unzip Ghost-0.7.0-zh-full.zip
以上地址可能会更新,请以官网的为主。
本地测试运行cp config.example.js config.js
本地环境测试运行不用改任何配置(数据库默认使用SQLite):
node index.js
正常运行会输出:
Migrations: Up to date at version 004 Ghost is running in development... Listening on 127.0.0.1:2368 Url configured as: http://localhost:2368 Ctrl+C to shut down
在浏览器输入http://localhost:2368即可。但是通过node index.js启动的会独占窗口,也不稳定,建议仅测试的时候用。
配置 Ghost 域名 设置域名解析例如g.52fhy.com,添加A记录,设置记录值为主机的IP地址即可。
配置nginx在/usr/local/nginx/conf/vhosts/新增一个配置文件g.52fhy.com.conf,内容为:
server { listen 80; server_name g.52fhy.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作为Ghost博客的反向代理。
重启nginx
/usr/local/nginx/sbin/nginx -s relaod让 Ghost 一直运行
前面提到的启动 Ghost 使用 npm start 命令。这是一个在开发模式下启动和测试的不错的选择,但是通过这种命令行启动的方式有个缺点,即当你关闭终端窗口或者从 SSH 断开连接时,Ghost 就停止了。为了防止 Ghost 停止工作,有两种方式解决这个问题。
Forever你可以使用 forever 以后台任务运行 Ghost 。forever 将会按照 Ghost 的配置,当进程 crash 后重启 Ghost。
通过 npm install forever -g 安装 forever; 运行Ghost forever start index.js[root@test ghost]# NODE_ENV=production forever start index.js warn: --minUptime not set. Defaulting to: 1000ms warn: --spinSleepTime not set. Your script will exit if it does not stay up for at least 1000ms info: Forever processing file: index.js [root@test ghost]# forever list info: Forever processes running data: uid command script forever pid id logfile uptime data: [0] 0JVT /usr/bin/node index.js 12148 12157 /root/.forever/0JVT.log 0:0:0:1.555Supervisor
流行的 Linux 发行版——例如 Fedora, Debian 和 Ubuntu,都包含一个 Supervisor 包:一个进程控制系统,允许在启动的时候无需初始化脚本就能运行 Ghost。不像初始化脚本一样,Supervisor 可以移植到不同的发行版和版本。
根据不同的 Linux 发行版 安装 Supervisor 。如下所示:
Debian/Ubuntu: apt-get install supervisor Fedora: yum install supervisor 其他大多数发行版: easy_install supervisor 通过 service supervisor start 确保 Supervisor 运行 为 Ghost 创建一个启动脚本。通常为 /etc/supervisor/conf.d/ghost.conf ,例如:[program:ghost] command = node /path/to/ghost/index.js directory = /path/to/ghost user = ghost autostart = true autorestart = true stdout_logfile = /var/log/supervisor/ghost.log stderr_logfile = /var/log/supervisor/ghost_err.log environment = NODE_ENV="production"
使用 CDN 缓存页面可以加快访问速度,减轻服务器的压力。
免费的 CDN 有很多,这里就不列举了。
给Ghost博客设置SMTP只需要编辑:vim config.js,在production下的Mail中加入SMTP信息即可。
mail: { transport: SMTP, options: { service: Gmail, auth: { user: youremail@gmail.com, pass: yourpassword }Ghost博客Google Fonts字体、备份和设置Apache反代
1、Ghost博客默认的主题加载了Google Fonts,导致博客打开变慢或者根本上打不开,解决的办法就是去掉主题中加载的Google Fonts链接。
2、Ghost博客后台去掉Google Fonts需要进入到:core/server/views/default.hbs·和·core/server/views/user-error.hbs,把里面的fonts.googleapis.com链接删除了。
3、默认的主题去掉Google Fonts需要进入到:content/themes/casper/default.hbs,把里面的fonts.googleapis.com链接删除了。
4、Ghost博客备份与恢复。Ghost 博客的所有文章内容都是存储在 sqlite3 数据库中的,其位置是 /content/data/ghost.db。另外,所有上传的图片都放在了 /content/images/ 目录下。
5、Ghost博客自带了一个备份与恢复的页面,地址是:域名/ghost/debug/。 点击 Export 按钮就可以将博客内容导出为 .json 文件,还有一个导入工具 Import ,可以将 .json 格式的备份内容导入Ghost 系统。 最后一个红色按钮 Delete all content 是用来删除所有内容(即清空数据库)。
6、设置Apache反代。本文中使用了Nginx作为Ghost博客的反代,如果你喜欢使用Apache,可以用以下代码实现Apache反代Ghost。
7、CentOS(或Redhat)系统中,Apache 的配置文件位于/etc/httpd/conf.d目录下;而 Ubuntu 系统中则是位于 /etc/apache 目录下。将下面给出的这段配置信息添加到 Apache 的配置文件中(注意替代成你的域名):
NameVirtualHost *:80 VirtualHost *:80 ServerName your-domain-name.com ServerAlias www.your-domain-name.com ProxyRequests off ProxyPass / http://127.0.0.1:2368/ ProxyPassReverse / http:/127.0.0.1:2368/ /VirtualHost
8、如果你想用Apache反代多个Ghost博客,使用以下代码:
NameVirtualHost *:80 VirtualHost *:80 ServerName your-domain-name.com ServerAlias www.your-domain-name.com ProxyRequests off ProxyPass / http://127.0.0.1:2368/ ProxyPassReverse / http:/127.0.0.1:2368/ /VirtualHost VirtualHost *:80 ServerName yoursecond--domain-name.com ServerAlias www.yoursecond--domain-name.com ProxyRequests off ProxyPass / http://127.0.0.1:8080/ ProxyPassReverse / http://127.0.0.1:8080/ /VirtualHost
9、最后重启 Apache生效。
在 CentOS 系统中执行如下命令: service httpd restart;
在 Ubuntu 系统中执行: service apache2 restart。
阿里云服务器搭建Ghost博客教程 Ghost是一个基于Node.js开发的免费开源博客平台,用于简化个人博客和在线出版物的在线发布过程。本文介绍了部署Ghost博客的详细步骤。
Linux服务器---博客wordpress Wordpress Wordpress是一个开源的博客平台,是搭建个人博客的首选,用户可以去wordpress中文网站寻找帮助资料 1、下载wordpress软件(https://cn.wordpress.
相关文章
- 自然语言交流系统 phxnet团队 创新实训 项目博客 (八)
- 基于springboot框架的博客系统
- laravel搭建博客实战的教程实例
- Web2.0网站的路径依赖--探讨蚂蚁社区为什么要导入博客
- django 简易博客开发 1 安装、创建、配置、admin使用
- 我的博客即将入驻“云栖社区”,诚邀技术同仁一同入驻。
- 【收藏】go博客 zxysilent / blog
- DayDayUp:Markdown编辑器的简介、入门、使用方法(Markdown编辑器撰写博客)
- 编辑文章 - 博客频道 - CSDN.NET
- 通过GitHub和Hexo搭建个人博客
- Hexo+GithubPage搭建Fan主题的博客(11)为Hexo博客的valine评论系统配置邮件通知