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/