從無到有,打造Ruby on Rails網站~~~
(摸了好久......)
1. apt-get update/upgrade
2. install vim
3. install postgresql
sudo apt-get install libpq-dev
sudo apt-get install postgresql-client postgresql
apt-get install pgadmin3
/etc/postgresql/9.1/main/postgresql.conf : listen_addresses = 'localhost'
/etc/postgresql/8.4/main/pg_hba.conf : md5
sudo -u postgres psql template1
ALTER USER postgres with encrypted password 'your_password';
\q
然後之後就用username: postgres password: your_password 來填 rails 的 config/database.yml
https://help.ubuntu.com/10.04/serverguide/postgresql.html
http://programmer.shinchi.tw/2013/06/07/%E5%9C%A8ubuntu12-04lts%E4%B8%8A%E5%AE%89%E8%A3%9Dapachepostgresqlrubyrails/
4. RoR (ruby rails gem rvm)
step 1~4 in [https://www.digitalocean.com/community/articles/how-to-install-rails-and-nginx-with-passenger-on-ubuntu]
curl -L get.rvm.io | bash -s stable
source /etc/profile.d/rvm.sh
rvm requirements
rvm install 2.0.0 (ruby version)
rvm use 2.0.0 --default
rvm rubygems current
gem install rails
5. 來個rails app吧
[http://ruby.railstutorial.org/chapters/a-demo-app?version=4.0#top]
apt-get install nodejs
sudo -u postgres createdb app1_dev / test / pro (bundle exec rake db:migrate)
gem 'pg' 'puma'
6. http://ruby-journal.com/how-to-setup-rails-app-with-puma-and-nginx/
!「bundle exec rake db:migrate RAILS_ENV=production」
7. git
[http://www.git-scm.com/book/en/Getting-Started-Installing-Git]
[http://ruby.railstutorial.org/chapters/beginning?version=4.0#sec-git_setup]
8. heroku
[https://toolbelt.heroku.com/debian]
[http://ruby.railstutorial.org/chapters/beginning?version=4.0#sec-heroku_setup]
[https://devcenter.heroku.com/articles/keys]
heroku run rake db:migrate
[https://devcenter.heroku.com/articles/rails4-getting-started]
production環境面臨的問題:
assets正常讀入及顯示:
有改到asset,就要執行RAILS_ENV=production bundle exec rake assets:precompile
#config/environments/production.rb
config.assets.compile = true
config.assets.initialize_on_precompile=false
---
個人常用筆記:
rails c --environment production
pumactl -P /var/run/puma.pid restart
rake db:migrate RAILS_ENV=production
---
其他debug:
sudo /usr/sbin/sshd -Dd