> 機器環境:Win7 64位
-
**安裝rubyinstaller.**
1.
到[http://rubyinstaller.org/downloads/](http://rubyinstaller.org/downloads/ "http://rubyinstaller.org/downloads/")下載ruby安裝文件,這里下載**rubyinstaller-2.2.3-x64.exe**,按照提示安裝,勾選Add Ruby executables to your PATH.

1.
Win7 64位默認安裝位置:C:\Ruby22-x64.
1. 驗證ruby是否安裝成功:cmd中`ruby -v`顯示ruby版本號說明ruby安裝成功.
-
**安裝rubygems.**
1. 官網下載安裝包[https://rubygems.org/pages/download](https://rubygems.org/pages/download "https://rubygems.org/pages/download")
1. 解壓rubygems-2.4.8.zip到指定目錄,為了方便管理解壓后放到C:\Ruby22-x64\目錄下.
1. cmd進入rubygems-2.4.8目錄下(快捷鍵:打開C:\Ruby22-x64\rubygems-2.4.8目錄,shift+鼠標右鍵,點擊”在此處打開命令行窗口”),運行`ruby setup.rb` .cmd 中 `gem -v` 顯示版本號則說明正常.
-
**安裝DevKit-mingw64**
1. 下載相應版本[http://rubyinstaller.org/downloads/](http://rubyinstaller.org/downloads/ "http://rubyinstaller.org/downloads/"),在C:\Ruby22-x64\目錄下新建DevKit文件夾,運行**DevKit-mingw64-64-4.7.2-20130224-1432-sfx.exe**后會提示解壓目錄,選擇C:\Ruby22-x64\DevKit.
1.
在C:\Ruby22-x64\DevKit中打開cmd,運行`ruby dk.rb init`,會提示配置config.yml.

1.
打開C:\Ruby22-x64\DevKit目錄下的config.yml,將ruby根目錄加入到配置文件中,這里是C:/Ruby22-x64.如果有了就不需要再加.注意格式.

1.
執行ruby dk.rb install.
-
**替換rubyGem庫地址(相當重要,因為國內訪問外網有線路問題,不僅更新速度慢,而且還會導致更新失敗)**
1. gem sources –remove [https://rubygems.org/](https://rubygems.org/)
1. gem sources -a [https://ruby.taobao.org/](https://ruby.taobao.org/) (注意:一定是https,淘寶已暫停http的ruby服務)
1. gem sources -l驗證一下.

-
**安裝rails**
1. cmd運行gem install rails.
1. cmd運行rails -v顯示rails版本號說明安裝成功.
- **安裝jekyll**
1. cmd運行gem install jekyll
1. cmd運行jekyll -v驗證,顯示版本號說明安裝成功.
環境配置完整之后,下面進入正題,如何新建博客:
-
運行命令:jekyll new 文件夾名,比如jekyll new blog,會在當前目錄生成blog文件夾.

-
在生成的blog文件夾根目錄下運行命令:jekyll serve –watch
-
瀏覽器中打開localhost:4000,命令運行過程中沒有錯誤提示,瀏覽器中顯示默認頁面說明安裝成功.

-
使用markdown發布博客
1.
markdown是什么? 參考淘寶UED關于markdown的介紹[http://ued.taobao.org/blog/2012/07/getting-started-with-markdown/](http://ued.taobao.org/blog/2012/07/getting-started-with-markdown/ "http://ued.taobao.org/blog/2012/07/getting-started-with-markdown/"). 錘子手機發布會上羅永浩介紹了錘子科技出品的app**錘子便簽**支持markdown功能,下載地址:[http://bbs.smartisan.com/forum-92-1.html](http://bbs.smartisan.com/forum-92-1.html "錘子便簽app"),非常好用,建議下載體驗一番.
1.
將markdown、html格式的文件以”YY-MM-DD-finename.filetype”命名放到_post文件夾下:如2015-09-10-firstpost.markdown.
-
發布到github
1. 首先注冊一個[github](https://github.com/)賬號.
1. 新建repository,以username.github.io的形式命名.
1. git提交本地代碼到github.
1. git提交命令
- git init
- git add .
- git commit -m “update”
- git remote add origin [https://github.com/cseryp/cseryp.github.io.git](https://github.com/cseryp/cseryp.github.io.git)
- git push -u origin master
-
參考文章
1. [每個人都應該有一個Jekyll博客](http://www.cellier.me/2015/01/04/jekyll%E6%90%AD%E5%BB%BA%E5%8D%9A%E5%AE%A2%E6%95%99%E7%A8%8B/)
1. [git教程](http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000)
-
`jekyll 2.5.3 | Error: Permission denied - bind(2) for 127.0.0.1:4000` 出現這個錯誤說明端口被占有,打開_config.yml,加入一行:port:5001(沒有被占用的端口均可)即可解決.