Total Pageviews

Tuesday, 10 April 2012

Octopress:一个geek级的建站程序



Octopress Setup

First, I want to stress that Octopress is a blogging framework for hackers. You should be comfortable running shell commands and familiar with the basics of Git. If that sounds daunting, Octopress probably isn’t for you.

Before You Begin

You’ll need to install Git and set up your Ruby environment. Octopress requires Ruby 1.9.2 wich you can easily install with RVM or rbenv. You can’t use both rbenv and RVM on the same system, as they are competing Ruby environment managers, so choose one.

Using RVM

If you don’t have RVM yet, Install RVM and then install Ruby 1.9.2.
1
rvm install 1.9.2 && rvm use 1.9.2

Using rbenv

If you don’t have rbenv yet, Install rbenv and install ruby-build, then install Ruby 1.9.2.
1
rbenv install 1.9.2-p290

Setup Octopress

1
2
3
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).
ruby --version  # Should report Ruby 1.9.2
If ruby --version doesn’t say you’re using Ruby 1.9.2, you may want to revisit your RVM installation.
Next, install dependencies.
1
2
3
gem install bundler
rbenv rehash    # If you use rbenv, rehash to be able to run the bundle command
bundle install
Install the default Octopress theme.
1
rake install

Next Steps

from http://octopress.org/docs/setup/
相关帖子:http://briteming.blogspot.co.uk/2012/01/rubyoctopress.html
---------------------------------------------
 Setup Octopress(我的安装过程)
首先
# apt-get install git -y (或者yum install git -y)
然后编译ruby:
# wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p125.tar.gz
# tar zxvf ruby-1.9.3-p125.tar.gz
# cd  ruby-1.9.3-p125
# ./configure --prefix=/usr/local/ruby
# make
# make install
# ln -s  /usr/local/ruby/bin/ruby /usr/bin/ruby
# ln -s /usr/local/ruby/bin/gem /usr/bin/gem

#git clone git://github.com/imathis/octopress.git
#cd octopress
#gem install bundler

#cd /root
#git clone git://github.com/sstephenson/rbenv.git
#ln -s /root/rbenv/bin/rbenv /usr/bin/rbenv
#cd /root/octopress
#rbenv rehash
#ln -s /usr/local/ruby/bin/bundle /usr/bin/bundle
#bundle install
#ln -s /usr/local/ruby/bin/rake /usr/bin/rake
#bundle exec rake install

 如若出错:
$ rake install
rake aborted!
You have already activated rake 0.9.2.2, but your Gemfile requires rake 0.9.2. Using bundle exec may solve this.
(See full trace by running task with --trace)
修正办法为:
$ bundle update

$ rake install

 (发布博客到github pages
a. 与github建立连接
# rake setup_github_pages
按照提示输入 github page repository的url地址,例如:git@github.com:careychow/careychow.github.com.git



b. 生成静态页面
# rake generate

# rake deploy

 配置 Octopress
更新配置文件 octopress/_config.yml, ,参考http://octopress.org/docs/configuring,示例如下,若包含中文,请将文件格式保存成utf-8的格式-

url: http://surmount.github.com/
title: 润物无声
subtitle: 天空一朵雨做的云
author: ym
simple_search: http://google.com/search
description:



绑定个人域名
echo 'op.brite.biz' >> octopress/source/CNAME

添加域名 'op.brite.biz’的 CNAME记录到UR-USERNAME.GITHUB.COM,如果你的域名是根域名,则添加你的根域名的A记录到 207.97.227.245


 创建新文章
rake new_post["POSTNAME"]



发布到github空间
rake generate
rake deploy )  



 我发布到github空间失败,不过发布(同步)到我的linux vps空间成功。操作如下:

Deploying with rsync via SSH TO YOUR LINUX VPS

修改下载所得的octopress源码里的Rakefile文件如下. To deploy with rsync TO YOUR LINUX VPS, be sure your public key is listed in your target server's ~/.ssh/authorized_keys file.




ssh_user       = "username@ur-vps-host.com"
ssh_port       = "your linux vps ssh port number"
document_root  = "~/website.com/"
rsync_delete   = true
deploy_default = "rsync"
Now if you run
# rake generate   (If you haven't generated your blog yet)
# rake deploy     (Sync your blog via ssh to ur linux vps)

your "public" directory will be synced to your vps server’s document root.

创建新文章:
# rake new_post["POSTNAME"]





发布到你的linux vps空间:
# rake generate
# rake deploy  


from http://octopress.org/docs/deploying/rsync/
示例: http://op.brite.biz/

编辑较长的帖子时,可插入<!--more-->到你的帖子的某个位置,以达到
 read more 的效果。     参见http://octopress.org/docs/blogging,
进阶设置,参见http://octopress.org/docs/
至此,一个完整的OCTOPRESS博客就搭建完毕了,具体的运行效果请参见我的示例空间-
http://op.brite.biz/