1.安装rvm
curl https://rawgithub.com/wayneeseguin/rvm/master/binscripts/rvm-installer | bash -s stable
网上不少教程用raw.github这个站点,但目前须要使用去除”.“的网址shell
2.将rvm命令添加到系统path中
echo ‘[[ -s “$HOME/.rvm/scripts/rvm” ]] && . “$HOME/.rvm/scripts/rvm” # Load RVM function’ >> ~/.bash_profile
source ~/.bash_profile
若是不作这一步,第3步的”rvm use 1.9.3”将不起做用ruby
3.安装ruby1.9.3
rvm install 1.9.3 或者用2.0也能够
rvm use 1.9.3 或者用2.0也能够
这是下载ruby和rubygem源代码后本地自动编译安装.ruby和rubygem的版本要对应,这里会自动解决。bash
此时,能够查看ruby版本:ruby —version 我在shell下看到的是:ruby 1.9.3p448 (2013-06-27 revision 41675) [x86_64-linux]markdown
4.确保你装了git
用git —version查看版本
若是没有安装git,那就sudo yum install git-coredom
5.下载octopress
不要认为是网页上的“下载”,这里是用git的方式:
cd ~/workspace/blog
git clone git://github.com/imathis/octopress.git octopress
若是下载速度超慢请尝试修改hostsssh
6.安装bundle
cd octopress
gem install bundler
bundle install
这里很奇怪,先前bundle的时候一直报错,换成ruby.taobao.org仍是报错,但此次没有修改Gemfile居然下载安装无阻。curl
7.安装主题
rake install [‘theme-name’]
若是只是rake install表示安装默认主题(位于octopress/.theme)
这里若是遭遇rake install aborted错误,说rake版本不正确,由于rvm帮咱们下载了0.9的版本,可是若是用yum install的话装的是10.x的版本,须要先yum remove rake。。感受ruby的包管理机制真烦。
8.后续操做
生成模板:
rake generate
本地预览:
rake preview
能够经过127.0.0.1的4000端口查看
添加新文章
rake new_post[“文章标题”] //能够直接输入中文,Octopress 自动将汉字转换成拼音url
例如:rake new_post[“hello”]
会在source/_post/生成hello.markdown的文件
用文本编辑器打开后编辑便可。
添加新页面
rake new_page[“about”]
其余的编辑项
blog的配置信息修改: _config.ym
9.部署到github
须要先在github上创建一个repo,名字格式为username.github.io
官方主页的说明https://help.github.com/articles/user-organization-and-project-pages
而后是rake setup_github_pages
会询问你的repo的地址,填写你刚刚创建的repo的全称。
若是使用git@的形式,须要github的ssh设定过,不然会报错:
ssh-keygen
文件名取为/home/username/.ssh/github
而后就生成了key,复制/home/username/.ssh/github.pub中的内容,粘贴到github上account setting中的ssh key里面就ok了。
而后是部署:
rake deploy
若是github上比本地版本高则部署会失败,能够修改Rakefile第264行,“#”前添加“+”便可
ok,查看一下,好比个人:zchrissirhcz.github.com
能够看到octopress已经在了!
10.域名绑定
官方的帮助:https://help.github.com/articles/setting-up-a-custom-domain-with-pages 好比在godaddy买了example.com域名,而后把A记录改成 204.232.175.78(git page) 而后在本地octopress/source目录下新建CNAME文件,填写example.com
听说国外DNS容易被墙,索性换成DNSPOD好了
总结:
新建文章:rake new_page[‘文章名’]
增删改查:在octopress/source/_posts中进行
生成:rake generate 预览:rake preview 部署:rake deploy
参考:
http://beyondvincent.com/blog/2013/08/03/108-creating-a-github-blog-using-octopress/ http://easypi.github.io/blog/2013/01/05/using-octopress-to-setup-blog-on-github/ http://ginsmile.github.io/blog/2013/08/29/octopressbo-ke-ji-qiao/#.UkfO2x0W1q8 http://beiyuu.com/github-pages/