2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

centOS6.7のconohaVPSでrailsappを走らせるまで

2
Last updated at Posted at 2015-10-02

前置き

conohaの中の人達にお世話になったので借りてrails走らせてみた
ただの備忘録です
調べれば沢山出てくるはず
ansibleとかはいずれかければ
rubyは2.2.0
railsは4.2.0

事前設定

useradd hoge
passwd hoge
su hoge
cd
mkdir .ssh
vi .ssh/authorized_keys
# 公開鍵貼り付け
exit #rootに戻る
visudo #hogeにsudo権限付ける
yum install -y git gcc gcc-c++ openssl-devel readline-devel zlib-devel libcurl-devel

rbenv

cd /usr/local
git clone git://github.com/sstephenson/rbenv.git rbenv
mkdir rbenv/shims rbenv/versions rbenv/plugins
groupadd rbenv
chgrp -R rbenv rbenv
chmod -R g+rwxXs rbenv
cd /usr/local/rbenv/plugins

# ruby build
git clone git://github.com/sstephenson/ruby-build.git ruby-build
chgrp -R rbenv ruby-build
chmod -R g+rwxs ruby-build
rbenv install -l

# ruby-default-gems(勝手にgem入れてくれる奴)
git clone git://github.com/sstephenson/rbenv-default-gems.git rbenv-default-gems
chgrp -R rbenv rbenv-default-gems
chmod -R g+rwxs rbenv-default-gems
vim /etc/profile.d/rbenv.sh
vim /usr/local/rbenv/default-gems
/etc/profile.d/rbenv.sh
export RBENV_ROOT="/usr/local/rbenv"
export PATH="$RBENV_ROOT/bin:$PATH"
eval "$(rbenv init -)"
/usr/local/rbenv/default-gems
bundler
rbenv-rehash
source /etc/profile.d/rbenv.sh
rbenv install *.*.*
rbenv global *.*.*

※ 2.2.0入れる時は以下が必要
yum install libffi-devel

nginx

rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
yum -y install nginx
chkconfig nginx on
service nginx start
# IPでアクセスして起動画面確認

rails 設定

git clone git@hogehoge
sudo chown -R username hogehoge
bundle install

# nokogiri で怒られたので以下を実行
bundle config build.nokogiri --use-system-libraries
sudo yum install libxml2-devel libxslt-devel

# sqlite3で怒られたので以下実行
sudo yum install -y sqlite-devel 

本番環境準備

bundle exec rake db:migrate RAILS_ENV=production

# js runtimeがないってさ
gem 'therubyracer'
を追加
bundle update
bundle install

bundle exec rake assets:precompile RAILS_ENV=production

# こんなエラーが出続けたので
rake aborted!
Sass::SyntaxError: File to import not found or unreadable: style.scss.
application.cssをscssにリネーム

unicorn.rb 追加

以下参照
http://omohayui.hatenablog.com/entry/2015/07/18/154837

起動

mkdir /var/run/unicorn
mkdir /var/log/unicorn

# 必要に応じて
sudo chown -R hoge folder_name

bundle exec unicorn_rails -c config/unicorn.rb -E production -D

確認と停止

# 確認
ps -ef | grep unicorn | grep -v grep

# 停止

kill -QUIT `cat /var/run/unicorn/unicorn.pid`

これでアプリが立ち上がります

参考

参考というかほぼコピペ、、、まとめただけ
http://kzy52.com/entry/2015/05/13/201831
http://shiro-16.hatenablog.com/entry/2014/12/26/003810

2
3
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
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?