Last active
April 21, 2016 16:49
-
-
Save na0AaooQ/f222376e2abfc3403d9b to your computer and use it in GitHub Desktop.
Amazon LinuxにRuby on Rails環境構築(rbenv + ruby-build + Ruby 2.2.1 + Rails 4.2.1インストール) ref: http://qiita.com/na0AaooQ/items/5bd62e630a2faf051a52
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo su - | |
# yum -y install git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ruby -v | |
ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-linux] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pwd | |
/root | |
# gem update --system | |
# gem install nokogiri -- --use-system-libraries | |
# gem install --no-ri --no-rdoc rails | |
# gem install bundler | |
# rbenv rehash | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pwd | |
/root | |
# rails -v | |
Rails 4.2.1 | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# gem list | |
*** LOCAL GEMS *** | |
actionmailer (4.2.1) | |
actionpack (4.2.1) | |
actionview (4.2.1) | |
activejob (4.2.1) | |
activemodel (4.2.1) | |
activerecord (4.2.1) | |
activesupport (4.2.1) | |
arel (6.0.0) | |
bigdecimal (1.2.6) | |
builder (3.2.2) | |
bundler (1.9.0) | |
erubis (2.7.0) | |
globalid (0.3.3) | |
hike (1.2.3) | |
i18n (0.7.0) | |
io-console (0.4.3) | |
json (1.8.1) | |
loofah (2.0.1) | |
mail (2.6.3) | |
mime-types (2.4.3) | |
mini_portile (0.6.2) | |
minitest (5.4.3) | |
multi_json (1.11.0) | |
nokogiri (1.6.6.2) | |
power_assert (0.2.2) | |
psych (2.0.8) | |
rack (1.6.0) | |
rack-test (0.6.3) | |
rails (4.2.1) | |
rails-deprecated_sanitizer (1.0.3) | |
rails-dom-testing (1.0.6) | |
rails-html-sanitizer (1.0.2) | |
railties (4.2.1) | |
rake (10.4.2) | |
rdoc (4.2.0) | |
rubygems-update (2.4.6) | |
sprockets (2.12.3) | |
sprockets-rails (2.2.4) | |
test-unit (3.0.8) | |
thor (0.19.1) | |
thread_safe (0.3.5) | |
tilt (1.4.1) | |
tzinfo (1.2.2) | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# cp -p /etc/passwd /etc/passwd.ORG | |
# cp -p /etc/shadow /etc/shadow.ORG | |
# cp -p /etc/group /etc/group.ORG | |
# groupadd rails | |
# useradd rails -g rails -d /home/rails -s /bin/bash | |
# id rails | |
uid=501(rails) gid=501(rails) groups=501(rails) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# su - rails | |
$ cd ~ | |
$ pwd | |
/home/rails | |
$ rails new sample --skip-bundle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cp -p /home/rails/sample/Gemfile /home/rails/sample/Gemfile.ORG | |
$ diff /home/rails/sample/Gemfile /home/rails/sample/Gemfile.ORG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cd /home/rails/sample | |
$ pwd | |
/home/rails/sample | |
$ echo "gem 'therubyracer'" >> /home/rails/sample/Gemfile | |
$ echo "gem 'sqlite3'" >> /home/rails/sample/Gemfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ bundle config build.nokogiri --use-system-libraries | |
$ bundle install --path=/home/rails/sample/vendor/bundle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ pwd | |
/home/rails/sample | |
$ gem list | |
*** LOCAL GEMS *** | |
actionmailer (4.2.1) | |
actionpack (4.2.1) | |
actionview (4.2.1) | |
activejob (4.2.1) | |
activemodel (4.2.1) | |
activerecord (4.2.1) | |
activesupport (4.2.1) | |
arel (6.0.0) | |
bigdecimal (1.2.6) | |
builder (3.2.2) | |
bundler (1.9.0) | |
erubis (2.7.0) | |
globalid (0.3.3) | |
hike (1.2.3) | |
i18n (0.7.0) | |
io-console (0.4.3) | |
json (1.8.1) | |
loofah (2.0.1) | |
mail (2.6.3) | |
mime-types (2.4.3) | |
mini_portile (0.6.2) | |
minitest (5.4.3) | |
multi_json (1.11.0) | |
nokogiri (1.6.6.2) | |
power_assert (0.2.2) | |
psych (2.0.8) | |
rack (1.6.0) | |
rack-test (0.6.3) | |
rails (4.2.1) | |
rails-deprecated_sanitizer (1.0.3) | |
rails-dom-testing (1.0.6) | |
rails-html-sanitizer (1.0.2) | |
railties (4.2.1) | |
rake (10.4.2) | |
rdoc (4.2.0) | |
rubygems-update (2.4.6) | |
sprockets (2.12.3) | |
sprockets-rails (2.2.4) | |
test-unit (3.0.8) | |
thor (0.19.1) | |
thread_safe (0.3.5) | |
tilt (1.4.1) | |
tzinfo (1.2.2) | |
$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# yum -y install gcc-c++ glibc-headers openssl-devel readline libyaml-devel readline-devel zlib zlib-devel libffi-devel libxml2 libxslt libxml2-devel libxslt-devel sqlite-devel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ pwd | |
/home/rails/sample | |
$ rails server -d -b 0.0.0.0 | |
=> Booting WEBrick | |
=> Rails 4.2.1 application starting in development on http://0.0.0.0:3000 | |
=> Run `rails server -h` for more startup options | |
$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ curl -s http://localhost:3000/ | grep "Ruby on Rails: Welcome aboard" | |
<title>Ruby on Rails: Welcome aboard</title> | |
$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ id | |
uid=501(rails) gid=501(rails) groups=501(rails) | |
$ | |
$ ps awux | grep -v grep | grep 'rails server' | |
rails 2776 0.0 7.8 539068 80132 ? Sl 00:11 0:00 /usr/local/rbenv/versions/2.2.1/bin/ruby bin/rails server -d -b 0.0.0.0 | |
$ ps awux | grep -v grep | grep 'rails server' | awk '{print $2}' | |
2776 | |
$ | |
$ ps awux | grep -v grep | grep 'rails server' | |
rails 2776 0.0 7.8 539068 80132 ? Sl 00:11 0:00 /usr/local/rbenv/versions/2.2.1/bin/ruby bin/rails server -d -b 0.0.0.0 | |
$ kill `ps awux | grep -v grep | grep 'rails server' | awk '{print $2}'` | |
$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ netstat -an | grep 3000 | |
$ | |
$ ps awux | grep -v grep | grep 'rails server' | |
$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# git clone https://github.com/sstephenson/rbenv.git /usr/local/rbenv | |
# cp -p /etc/profile /etc/profile.ORG | |
# diff /etc/profile /etc/profile.ORG | |
# | |
# echo 'export RBENV_ROOT="/usr/local/rbenv"' >> /etc/profile | |
# echo 'export PATH="${RBENV_ROOT}/bin:${PATH}"' >> /etc/profile | |
# echo 'eval "$(rbenv init -)"' >> /etc/profile | |
# source /etc/profile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# su - root | |
# env | grep RBENV | |
RBENV_ROOT=/usr/local/rbenv | |
RBENV_SHELL=bash | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# rbenv --version | |
rbenv 0.4.0-146-g7ad01b2 | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# git clone https://github.com/sstephenson/ruby-build.git /usr/local/rbenv/plugins/ruby-build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pwd | |
/root | |
# rbenv install -l | |
(中略) | |
2.1.5 | |
2.2.0-dev | |
2.2.0-preview1 | |
2.2.0-preview2 | |
2.2.0-rc1 | |
2.2.0 | |
2.2.1 → このバージョンをインストールします。 | |
2.3.0-dev | |
jruby-1.5.6 | |
(中略) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# rbenv install -v 2.2.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# rbenv rehash | |
# rbenv global 2.2.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
echo "User Data start" | |
yum -y update | |
unalias cp | |
cp -f -p /usr/share/zoneinfo/Japan /etc/localtime | |
cat << _EOT_ > /etc/sysconfig/clock | |
ZONE="Asia/Tokyo" | |
UTC=false | |
_EOT_ | |
chmod 644 /etc/sysconfig/clock | |
/etc/init.d/crond restart | |
echo "User Data end" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment