0
0

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.

HerokuのSet Up 1

0
Last updated at Posted at 2016-05-03

Create environment by vagrant

mkdir learning_rails
cd learning_rails
vagrant box add "centos_6.6" https://github.com/tommy-muehle/puppet-vagrant-boxes/releases/download/1.0.0/centos-6.6-x86_64.box
bash
vagrant init
vi Vagrantfile 
Vagrant.configure(2) do |config|
  config.vm.define "host" do |node|
    node.vm.box = "centos_6.6"
    node.vm.hostname = "host"
    node.vm.network :private_network, ip: "192.168.43.200"
  end
  config.ssh.insert_key = false
end
vagrant up
vagrant ssh

Change character set

bash
sudo vi /etc/sysconfig/i18n
text:/etc/sysconfig/i18n
LANG="ja_JP.UTF-8"

Install Ruby and Rails

su -
cd /usr/local/src/
wget https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.0.tar.gz
tar xvzf ruby-2.3.0.tar.gz
cd ruby-2.3.0
./configure
make
make install
gem install rails -v 4.1.15 --no-rdoc --no-ri

Install PostgreSQL

sudo rpm -i http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/pgdg-redhat93-9.3-3.noarch.rpm
sudo yum -y install postgresql93-server postgresql93-contrib postgresql-devel.x86_64
bash
sudo service postgresql-9.3 initdb
bash
sudo chkconfig postgresql-9.3 on
bash
sudo service postgresql-9.3 status
bash
sudo service postgresql-9.3 start
bash
sudo passwd postgres
bash
su - postgres
bash
psql
psql
create user vagrant createdb password 'testpassword' login;

exit

psql
\q

Set Up Rails app

It is root user now.

bash
mkdir -p /srv/www
bash
cd /srv
bash
chown vagrant:vagrant www

become vagrant user

bash
exit
bash
cd /srv/www
bash
rails new herokutest -d postgresql
bash
cd herokutest/
bash
vi Gemfile

comment in

Gemfile
gem 'therubyracer',  platforms: :ruby
bash
bundle install
bash
vi config/database.yml 

set these values.

database.yml
username: vagrant
password: testpassword
bash
rake db:create

You can check tables

bash
psql -l

Test to create user

bash
rails g scaffold User name age:integer
bash
sudo su - postgres
bash
createuser -P vagrant
bash
psql
bash
\du
bash
rake db:create
bash
rake db:migrate

You can run rails

bash
rails s

You can see it from this IP

http://192.168.43.200:3000/users
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?