Create Rails Application for Production
// Need to be perform DB User id creation steps if required new user production //
sudo -u postgres createuser -s sample2prod
ubuntu@ip-172-31-6-116:~$ sudo -u postgres psql
psql (9.3.6)
Type "help" for help.
postgres=# \password sample2prod
Enter new password:
Enter it again:
\q
ubuntu@ip-172-31-15-122:~$ rails new sample2prod -d postgresql
ubuntu@ip-172-31-15-122:~$ cd sample2prod/
ubuntu@ip-172-31-15-122:~/sample2prod$ vi config/database.yml
host: 172.31.15.122
username: sample2prod
password: <%= ENV['APPNAME_DATABASE_PASSWORD'] %>
ubuntu@ip-172-31-15-122:~/sample2prod$ cd ~/.rbenv/plugins
ubuntu@ip-172-31-15-122:~/sample2prod$ git clone https://github.com/sstephenson/rbenv-vars.git
ubuntu@ip-172-31-15-122:~/.rbenv/plugins$ cd ~/sample2prod
ubuntu@ip-172-31-15-122:~/sample2prod$
ubuntu@ip-172-31-15-122:~/sample2prod$ rake secret
c8061a577faf655b8b97d01adbb872d26d28b115c0c97bd4654895eefe21ca4dfababa67fc6d9481405d7fe7c5fdc02e456accfd26694c485c16bad3c4e6e0b8
ubuntu@ip-172-31-15-122:~/sample2prod$
ubuntu@ip-172-31-15-122:~/sample2prod$ vi .rbenv-vars
SECRET_KEY_BASE=c8061a577faf655b8b97d01adbb872d26d28b115c0c97bd4654895eefe21ca4dfababa67fc6d9481405d7fe7c5fdc02e456accfd26694c485c16bad3c4e6e0b8
APPNAME_DATABASE_PASSWORD=sample2prod
ubuntu@ip-172-31-15-122:~/sample2prod$ rbenv vars
# /home/ubuntu/sample2prod/.rbenv-vars
export SECRET_KEY_BASE='c8061a577faf655b8b97d01adbb872d26d28b115c0c97bd4654895eefe21ca4dfababa67fc6d9481405d7fe7c5fdc02e456accfd26694c485c16bad3c4e6e0b8'
export APPNAME_DATABASE_PASSWORD='sample2prod'
ubuntu@ip-172-31-15-122:~/sample2prod$ APPNAME_DATABASE_PASSWORD=production rake db:create
ubuntu@ip-172-31-15-122:~/sample2prod$ rails generate scaffold Task title:string note:text
invoke active_record
create db/migrate/20150412075433_create_tasks.rb
create app/models/task.rb
invoke test_unit
create test/models/task_test.rb
create test/fixtures/tasks.yml
invoke resource_route
route resources :tasks
invoke scaffold_controller
create app/controllers/tasks_controller.rb
invoke erb
create app/views/tasks
create app/views/tasks/index.html.erb
create app/views/tasks/edit.html.erb
create app/views/tasks/show.html.erb
create app/views/tasks/new.html.erb
create app/views/tasks/_form.html.erb
invoke test_unit
create test/controllers/tasks_controller_test.rb
invoke helper
create app/helpers/tasks_helper.rb
invoke test_unit
invoke jbuilder
create app/views/tasks/index.json.jbuilder
create app/views/tasks/show.json.jbuilder
invoke assets
invoke coffee
create app/assets/javascripts/tasks.coffee
invoke scss
create app/assets/stylesheets/tasks.scss
invoke scss
create app/assets/stylesheets/scaffolds.scss
ubuntu@ip-172-31-15-122:~/sample2prod$ APPNAME_DATABASE_PASSWORD=production rake db:migrate
== 20150412075433 CreateTasks: migrating ======================================
-- create_table(:tasks)
-> 0.0091s
== 20150412075433 CreateTasks: migrated (0.0093s) =============================
ubuntu@ip-172-31-15-122:~/sample2prod$ APPNAME_DATABASE_PASSWORD=production rails server --binding=192.168.100.46
=> Booting WEBrick
=> Rails 4.2.0 application starting in development on http://172.31.15.122:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2015-04-12 07:55:36] INFO WEBrick 1.3.1
[2015-04-12 07:55:36] INFO ruby 2.2.1 (2015-02-26) [x86_64-linux]
[2015-04-12 07:55:36] INFO WEBrick::HTTPServer#start: pid=22555 port=3000
Started GET "/" for 103.8.194.117 at 2015-04-12 07:55:49 +0000
Cannot render console from 103.8.194.117! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
ActiveRecord::SchemaMigration Load (0.3ms) SELECT "schema_migrations".* FROM "schema_migrations"
Processing by Rails::WelcomeController#index as HTML
Rendered /home/ubuntu/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/railties-4.2.0/lib/rails/templates/rails/welcome/index.html.erb (1.3ms)
Completed 200 OK in 14ms (Views: 6.2ms | ActiveRecord: 0.0ms)
^C[2015-04-12 07:55:58] INFO going to shutdown ...
[2015-04-12 07:55:58] INFO WEBrick::HTTPServer#start done.
Exiting
http://34.234.76.122:3000
**If you see the "Welcome aboard" Ruby on Rails page**
No comments:
Post a Comment