本文主要参照Octopress Setup来搭建博客,数月前我曾写了Octopress的落成,当时刚上手,迷迷糊糊就搭建好了博客,就两个时间点的比较而言,自认为对git以及ssh都相对熟练了许多,因此对搭建博客的整个流程都不再是迷迷糊糊过来的,所以最好你是熟悉ssh和git的,git的教程可以访问git-scm.com/book/zh,需要梯子。
下面开始搭建了……
git
首先安装git
sudo apt-get install git
Ruby 1.9.3 by RVM
然后安装Ruby1.9.3,教程说有两种方法——rbenv or RVM,我选择了后者。
RVM
先装RVM,参考Installing Ruby With RVM
sudo apt-get install curl
下面的命令不要执行了…翻到下面RVM again
curl -L https://raw.githubusercontent.com/rvm/rvm/master/binscripts/rvm-installer | bash -s stable --ruby
执行完毕后输出的信息包含一下内容:
# [username],
#
# Thank you for using RVM!
# I sincerely hope that RVM helps to make your life easier and
# more enjoyable!!!
#
# ~Wayne
try Ruby 1.9.3
sudo apt-get install ruby-rvm
rvm install 1.9.3
在执行完上个命令的时候我没看仔细就开始了这个步骤,然后就有了如下的错误信息,其实上个步骤也有错误信息,选择性忽视掉了红字。
ERROR: The requested url does not exist: 'ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-.tar.bz2'
ERROR: Error running 'bunzip2 < '/usr/share/ruby-rvm/archives/ruby-1.9.3-.tar.bz2' | tar xf - -C /usr/share/ruby-rvm/tmp/rvm_src_8445', please read /usr/share/ruby-rvm/log/ruby-1.9.3/extract.log
ERROR: There has been an error while trying to extract the source.
Halting the installation.
ERROR: There has been an error fetching the ruby interpreter. Halting the installation.
回去看才发现有两段错误信息
part 1:
* WARNING: You're using ~/.profile, make sure you load it,
add the following line to ~/.bash_profile if it exists
otherwise add it to ~/.bash_login:
source ~/.profile
part 2:
Missing required packages: git-core.
RVM autolibs is now configured with mode '2' => 'check and stop if missing',
please run `rvm autolibs enable` to let RVM do its job or run and read `rvm autolibs [help]`
or visit https://rvm.io/rvm/autolibs for more information.
back to RVM
回去重装RVM,执行
curl -L https://get.rvm.io | bash -s stable --ruby
这次提示有些不同,他检测到RVM有错误:
It looks you are one of the happy Ubuntu users,
RVM packaged by Ubuntu is old and broken,
follow this link for details how to fix:
http://stackoverflow.com/a/9056395/497756
不过他提供了一个网址,来自著名的stackoverflow,以下内容选自stackoverflow:
You have broken version of RVM. Ubuntu does something to RVM that produces lots of errors, the only safe way of fixing for now is to:
sudo apt-get --purge remove ruby-rvm
sudo rm -rf /usr/share/ruby-rvm /etc/rvmrc /etc/profile.d/rvm.sh
open new terminal and validate environment is clean from old RVM settings (should be no output): (这里说要启动新的终端,应该不会输出什么)
env | grep rvm
if there was output, try to open new terminal, if it does not help then restart your computer.(如果有输出要尝试启动新终端,不然就重启电脑。PS:我没启动新终端没输出,一开理解错误,我启动新终端,有输出,然后我以为正常了,然后开始了下面的操作。。。晕)
RVM again
install RVM://期间输入三次左右的密码,下面的命令斜杠不是我加进去的,最好不要漏了
\curl -L https://get.rvm.io | bash -s stable --ruby --autolibs=enable --auto-dotfiles
好像下面是输出:
If you find you need some hand-holding, take a look at [Installing Ruby on Ubuntu 12.04](http://blog.coolaj86.com/articles/installing-ruby-on-ubuntu-12-04.html), which gives a bit more explanation.
* To start using RVM you need to run `source /home/liaobz/.rvm/scripts/rvm`
in all your open shell windows, in rare cases you need to reopen all shell windows.
Ruby 1.9.3
运行
rvm install 1.9.3
输一次密码之后再下载,我擦嘞,9789K的东西提示我要40多分钟,我想先去看一集《权利的游戏》了……操蛋的ubuntu12.04自带的电影播放机,ass和srt都加载不了,好在有深度影音……那可是人家葬礼啊,让个小子在那里卖萌(那小子是死者儿子…)……兰尼斯特家的侏儒也来卖萌……终于装完了……深度影音暂停后最小话会自动播放,播放放最小话才是暂停……
言归正传,先改个东西,选择终端->菜单->编辑(Edit)->配置文件首选项(Profile Preferences)->标题和命令(Title and Command)->命令(Command)->勾上以登录Shell方式运行命令(Run command as a login shell)
快捷一点就是先选中终端窗口,Alt+E,O,然后剩下的看上面
接着执行(貌似还得重启终端)
rvm use 1.9.3
如果你偷懒没做上面的改动,会有下面的提示
RVM is not a function, selecting rubies with 'rvm use ...' will not work.
You need to change your terminal emulator preferences to allow login shell.
Sometimes it is required to use `/bin/bash --login` as the command.
Please visit https://rvm.io/integration/gnome-terminal/ for a example.
意思就是你还是要改
rvm rubygems latest
然后
usrname@pcname:~$ ruby --version
ruby 1.9.3p392 (2013-02-22 revision 39386) [x86_64-linux]
Ruby就算好了,可以← Return to setup了。
Setup Octopress
git clone git://github.com/imathis/octopress.git octopress
cd octopress # If you use RVM, You'll be asked if you trust the .rvmrc file (say yes).
提示了一大段,选yes,接着下两个命令都不会出上面大问题
gem install bundler
bundle install
如果你一边在看官网教程,你会发现上面有个rbenv rehash,那句不要执行,因为我用的RVM方式(# If you use rbenv, rehash to be able to run the bundle command),我貌似断了下网,Ctrl+C了一下,重新执行,输出以下内容:
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.
rake install
Octopress Setup Done!
Next Steps Set up deployment
这次我选择Deploying to Github Pages »,上次的Heroku太慢了
Deploying to Github Pages
在登陆github前提下访问new Github repository,新建一个与用户名同名的repository,记住网页上提供的SSH地址,终端运行
rake setup_github_pages
输入刚才的SSH地址,输出提示若干,接着终端运行
rake generate
rake deploy
此时应该是算完成了的,我自己倒是粗心做了比较多多余的事。官方说改动在十分钟左右生效,我的在提交过了十分钟还是不能访问,估计这个过程会稍微久一点。
PS:昨天后面太晚没去管了,回来发现liaobz.github.io还是上不去,反倒是liaobz.github.io/liaobz可以上去了。我发誓我是参照With Github User/Organization pages来的,而不是参照的With Github Project pages (gh-pages),总之我不考究了。
最终还是发现了我失误在什么地方,毕竟gh-pages不能独立域名不幸福啊……我新建的Repository Name是liaobz,这是错误的,正确的应该是liaobz.github.com,嗯 就这么多。
本文特地尽可能多的将错误步骤贴上博客,希望被官方教程误导了的同学可以检索到,从而解决乃至避免错误,本文难免有疏漏/错误的地方,欢迎不吝指出。
下面是一点点补充,如果你的执行步骤中出现了以下语句
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:
git config --global user.name "Your Name"
git config --global user.email you@example.com
After doing this, you may fix the identity used for this commit with:
git commit --amend --reset-author
你最好先按顺序执行这三条命令,设定用户名/密码,然后是修改提交信息吧好像
git config --global user.name "Your Name"
git config --global user.email you@example.com
git commit --amend --reset-author
执行rake deploy后输出的语句包含下面内容
## Pushing generated _deploy website
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
应该是忘了配SSH Keys了,自行补上即可。