LoginSignup
2
1

More than 5 years have passed since last update.

さくらVPS(CentOS6)にJekyllデプロイ。

Last updated at Posted at 2015-07-17

ローカルMacのjekyll -> さくらVPS(CentOS6)へデプロイ。
ローカルMacのrubyはrbenvで2.2.2をインストールして設定。

さくらVPS(CentOS6)にrbenvインストール

# cd /opt
# git clone git://github.com/sstephenson/rbenv.git
# mkdir /opt/rbenv/plugins
# cd /opt/rbenv/plugins
# git clone git://github.com/sstephenson/ruby-build.git
/etc/profile
export RBENV_ROOT="/opt/rbenv"
export PATH="${RBENV_ROOT}/bin:${PATH}"
eval "$(rbenv init -)"

さくらVPS(CentOS6)にRuby 2.2.2インストール

rbenvでRuby2.2.2を入れる。

# rbenv install 2.2.2
# rbenv global 2.2.2
# rbenv rehash
# rbenv version
2.2.2 (set by /opt/rbenv/version)

gitリポジトリ作成

プッシュ先のリポジトリ作成してプシュした時の

# cd /home/mysite
# mkdir myblog.git
# cd myblog.git
# git --bare init
# cp hooks/post-receive.sample hooks/post-receive
# cd /home/mysite
# mkdir tmp

git hook設定

copy /home/mysite/myblog.git/hooks/post-receive.sample
/home/mysite/myblog.git/hooks/post-receive
vi /home/mysite/myblog.git/hooks/post-receive

プッシュしたらBundle installしてJekyllサーバーして公開ディレクトリに静的ファイルを吐き出します。

/home/mysite/myblog.git/hooks/post-receive
pwd
echo 'post-receive'
ruby -v
rbenv version

git clone /home/mysite/myblog.git /home/mysite/tmp/repo

cd /home/mysite/tmp/repo
bundle install --path vendor/bundle
bundle exec jekyll build -s /home/mysite/tmp/repo -d /home/mysite/public

cd /home/mysite/tmp
rm -rf repo
exit
~  

プッシュした時にrbenvが効いていないのでエラーになる。

/etc/profileに書いたやつをプッシュするユーザーの.bashrcに書いたら動いた。

/home/mysite/.bashrc
export RBENV_ROOT="/opt/rbenv"
export PATH="${RBENV_ROOT}/bin:${PATH}"
eval "$(rbenv init -)"
2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1