How-to-install-octopress

系统是Mac OS X Lion 10.7.5

Step1 安装homebrew

ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"
brew update  

如果出现如下错误

error: unable to unlink old 'Library/Contributions/cmds/brew-test-bot/brew-test-bot.commit.html.erb' (Permission denied)  
error: unable to unlink old 'Library/Contributions/cmds/brew-test-bot/brew-test-bot.css' (Permission denied)  
error: unable to unlink old 'Library/Contributions/cmds/brew-test-bot/brew-test-bot.index.html.erb' (Permission denied)  
error: unable to unlink old 'Library/ENV/4.3/apr-1-config' (Permission denied)  
error: unable to unlink old 'Library/ENV/4.3/bsdmake' (Permission denied)  
error: unable to unlink old 'Library/ENV/4.3/c++' (Permission denied)  
error: unable to unlink old 'Library/ENV/4.3/c89' (Permission denied)  
error: unable to unlink old 'Library/ENV/4.3/c99' (Permission denied)  
error: unable to unlink old 'Library/ENV/4.3/cc' (Permission denied)  
error: unable to unlink old 'Library/ENV/4.3/clang' (Permission denied)  
error: unable to unlink old 'Library/ENV/4.3/clang++' (Permission denied)  
error: unable to unlink old 'Library/ENV/4.3/cpp' (Permission denied)  
error: unable to unlink old 'Library/ENV/4.3/g++' (Permission denied)  
error: unable to unlink old 'Library/ENV/4.3/gcc' (Permission denied)  
error: unable to unlink old 'Library/ENV/4.3/git' (Permission denied)  
error: unable to unlink old 'Library/ENV/4.3/i686-apple-darwin11-llvm-g++-4.2' (Permission denied)  
error: unable to unlink old 'Library/ENV/4.3/i686-apple-darwin11-llvm-gcc-4.2' (Permission denied)  
error: unable to unlink old 'Library/ENV/4.3/ld' (Permission denied)  
error: unable to unlink old 'Library/ENV/4.3/llvm-g++' (Permission denied)  
error: unable to unlink old 'Library/ENV/4.3/llvm-g++-4.2' (Permission denied)  
error: unable to unlink old 'Library/ENV/4.3/llvm-gcc' (Permission denied)  
error: unable to unlink old 'Library/ENV/4.3/llvm-gcc-4.2' (Permission denied)  
error: unable to unlink old 'Library/ENV/4.3/make' (Permission denied)  
error: unable to unlink old 'Library/ENV/4.3/mig' (Permission denied)  
error: unable to unlink old 'Library/ENV/4.3/sed' (Permission denied)  
error: unable to unlink old 'Library/ENV/4.3/svn' (Permission denied)  
error: unable to unlink old 'Library/ENV/4.3/xcrun' (Permission denied)  
error: unable to unlink old 'Library/ENV/libsuperenv.rb' (Permission denied)  
error: unable to unlink old 'Library/ENV/pkgconfig/leopard/libcrypto.pc' (Permission denied)  
error: unable to unlink old 'Library/ENV/pkgconfig/leopard/libcurl.pc' (Permission denied)  
error: unable to unlink old 'Library/ENV/pkgconfig/mountain_lion/libcurl.pc' (Permission denied)  
error: unable to unlink old 'Library/ENV/pkgconfig/mountain_lion/libexslt.pc' (Permission denied)  
error: unable to unlink old 'Library/ENV/pkgconfig/mountain_lion/libxml-2.0.pc' (Permission denied)  
error: unable to unlink old 'Library/ENV/pkgconfig/mountain_lion/libxslt.pc' (Permission denied)  
error: unable to unlink old 'Library/Homebrew/macos/xcode.rb' (Permission denied)  
error: unable to unlink old 'Library/Homebrew/macos/xquartz.rb' (Permission denied)  
fatal: Could not reset index file to revision 'origin/master'.  
Failed during: git reset --hard origin/master  

解决办法:sudo chown -R ${USER} /usr/local/Library

如果已经安装了Macports,先卸载掉

sudo rm -rf \  
/opt/local \  
/Applications/DarwinPorts \  
/Applications/MacPorts \  
/Library/LaunchDaemons/org.macports.* \  
/Library/Receipts/DarwinPorts*.pkg \  
/Library/Receipts/MacPorts*.pkg \  
/Library/StartupItems/DarwinPortsStartup \  
/Library/Tcl/darwinports1.0 \  
/Library/Tcl/macports1.0 \  
~/.macports

Step2 安装RVM

bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
source ~/.bashrc

Step3 安装Ruby

rvm install 1.9.3
rvm use 1.9.3 --default

Step4 安装Octopress

git clone git://github.com/imathis/octopress.git octopress  
gem install bundler  
bundle install
rake install

Step5 在github中托管

到目前我止,我们的blog仅能在本机中访问,如何将其托管到github中呢?如何使用我们自己的域名呢?让一切看起来就如同我们自己的站点。

如果你要使用自己的域名,github需要一个CNAME文件,进入source文件夹,新建CNAME文件。

$ ch source
$ touch CNAME

托管到github中

$ rake setup_github_pages

系统提示你输入一个形如:git@github.com:username/username.github.com.git,username是你在github.com中注册的用户名,username.github.com.git是你自己在github.com中创建的代码库。输入后按回车确定.

向github提交

$ rake generate
$ rake deploy

大概的步骤就是这么多,遇见别的问题去请教google大神吧