在CentOS,Ubuntu
按照一样步骤安装,Ruby Gems
每每都没法搭建成,每次都是依赖不对,各类奇葩缘由,解决办法就是使用 RVM
安装,解决 Ruby
的环境依赖管理,并且每次安装Jekyll
基本不会出错linux
本文主要介绍如何用一条靠谱的路子快速安装 Ruby
环境 搭建Jekyll
博客。git
jekyll
是一个简单的免费的Blog
生成工具,相似WordPress
。可是和WordPress
又有很大的不一样,缘由是Jekyll
只是一个生成静态网页的工具,不须要数据库支持。可是能够配合第三方服务,例如Disqus
。最关键的是jekyll能够免费部署在Github上,并且能够绑定本身的域名。github
CentOS 7.3 / Ubuntu 16.04 rvm 1.29.3 gem 2.5.1 ruby 2.3.0 jekyll 3.6.2
首先肯定操做系统环境,不建议在 Windows 上面搞,若是你必定想在Windows
上安装Jekyll
数据库
参考:http://www.ymq.io/2017/07/22/Windows-install-Jekyll/api
强烈新手使用 Ubuntu 省掉没必要要的麻烦!ruby
RVM 是干什么的这里就不解释了,自行Google,这里全部的命令都是再用户权限下操做的,任何命令最好都不要用 sudo
bash
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 curl -sSL https://get.rvm.io | bash -s stable # 若是上面的链接失败,能够尝试: curl -L https://raw.githubusercontent.com/wayneeseguin/rvm/master/binscripts/rvm-installer | bash -s stable
期间可能会问你 sudo
管理员密码,以及自动经过 Homebrew
安装依赖包,等待一段时间后就能够成功安装好 RVM
。服务器
而后,载入 RVM
环境(新开 Termal
就不用这么作了,会自动从新载入的)curl
source /usr/local/rvm/scripts/rvm
修改 RVM 的 Ruby 安装源到 Ruby China 的 Ruby 镜像服务器,这样能提升安装速度ide
echo "ruby_url=https://cache.ruby-china.org/pub/ruby" >> /usr/local/rvm/user/db
检查一下是否安装正确
$ rvm -v rvm 1.29.3 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
用 RVM 安装 Ruby 环境
$ rvm requirements $ rvm install 2.3.0
等待漫长的下载,编译过程,完成之后,Ruby, Ruby Gems
就安装好了,国内速度很慢,国外服务器,不到一分钟就下载完了,文件大概100兆
设置 Ruby 版本,一样,也能够用其余版本号,前提是你有用 rvm install 安装过那个版本
rvm use 2.3.0 --default
这个时候你能够测试是否正确
$ruby -v ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux] $gem -v 2.5.1
gem install bundler
搭建Jekyll博客,须要找一套主题模板,这里能够参考:https://www.zhihu.com/question/20223939 ,如下以 mzlogin.github.io 的主题为例
CentOS
yum install git
Ubuntu
apt install git
git clone https://github.com/mzlogin/mzlogin.github.io.git
cd souyunku.github.io/ bundle install
jekyll serve -H 0.0.0.0 -P 80
效果以下
Ubuntu 16.04
## Configuration file: /root/mzlogin.github.io/_config.yml Dependency Error: Yikes! It looks like you don't have jekyll-remote-theme or one of its dependencies installed. In order to use Jekyll as currently configured, you'll need to install this gem. The full error message from Ruby is: 'Could not open library 'libcurl': libcurl: cannot open shared object file: No such file or directory. Could not open library 'libcurl.so': libcurl.so: cannot open shared object file: No such file or directory. Could not open library 'libcurl.so.4': libcurl.so.4: cannot open shared object file: No such file or directory' If you run into trouble, you can find helpful resources at https://jekyllrb.com/help/! jekyll 3.6.2 | Error: jekyll-remote-theme
执行
apt-get install libcurl3
博客搭建成功以后,还须要作一些事情才能让你的页面「正确」跑起来。
如下内容摘自 码志 博客主题的,Fork 指南
按照 GitHub Pages 的规定,名称为 username.github.io
的项目的 master 分支,或者其它名称的项目的 gh-pages 分支能够自动生成 GitHub Pages 页面。
若是你须要绑定本身的域名,那么修改 CNAME 文件的内容;若是不须要绑定本身的域名,那么删掉 CNAME 文件。
网站的配置基本都集中在 _config.yml 文件中,将其中与我的信息相关的部分替换成你本身的,好比网站的 url、title、subtitle 和第三方评论模块的配置等。
评论模块: 目前支持 disqus、gitment 和 gitalk,选用其中一种就能够了,推荐使用 gitalk。它们各自的配置指南连接在 _config.yml 文件的 Comments 一节里都贴出来了。
注意: 若是使用 disqus,由于 disqus 处理用户名与域名白名单的策略存在缺陷,请必定将 disqus.username 修改为你本身的,不然请将该字段留空。我对该缺陷的记录见 Issues#2。
删除个人文章与图片。
以下文件夹中除了 template.md 文件外,均可以所有删除,而后添加你本身的内容。
pages/about.md 文件内容对应网站的「关于」页面,里面的内容多为我的相关,将它们替换成你本身的信息,包括 _data 目录下的 skills.yml 和 social.yml 文件里的数据。
个人我的博客外观基于 DONGChuan 的修改,感谢 Zhuang Ma !