Guest User

Untitled

a guest
Jun 17th, 2018
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.23 KB | None | 0 0
  1. # Install deprec
  2. sudo gem install deprec
  3.  
  4. # Create user on slicehost account (run on server)
  5. adduser --ingroup users yourusername
  6.  
  7. # Add new user to '/etc/sudoers' file (on server)
  8.  
  9. # Remove obsolete projects from '/etc/apache2/sites-available' and
  10. # '/etc/apache2/site-enabled' (on server)
  11.  
  12. ## If using github
  13. # Add ssh key to github
  14. cd .ssh
  15. ssh-keygen
  16. ssh-add id_rsa
  17. cat id_rsa.pub | pbcopy
  18. paste into github form
  19.  
  20. # Create ~/.ssh/config file
  21. Host github.com
  22. User git
  23. Port 22
  24. Hostname github.com
  25. IdentityFile ~/.ssh/id_rsa
  26. TCPKeepAlive yes
  27. IdentitiesOnly yes
  28.  
  29. # Config git
  30. git config --global user.name "Your Name"
  31. git config --global user.email your.email@gmail.com
  32.  
  33. # Add project to github
  34. cd yourappname
  35. git init
  36. touch README
  37. git add README
  38. git commit -m 'first commit'
  39. git remote add origin git@github.com:yourusername/yourappname.git
  40. git push origin master
  41.  
  42. ## If not using github
  43. # Add project to git
  44. cd yourappname
  45. git init
  46. mate .gitignore
  47. .DS_Store
  48. db/*.sqlite3
  49. log/*.log
  50. tmp/**/*
  51. touch log/.gitignore
  52. touch tmp/.gitignore
  53. git add .
  54. git commit -m 'first commit'
  55.  
  56. ## [shell]
  57. # Create deprec configuration files
  58. cd yourappname
  59. depify .
  60.  
  61. # Modify file 'config/deploy.rb':
  62. set :repository, "." # if not using github
  63. set :application, "yourappname"
  64. set :domain, "yourdomainname"
  65. set :user, "yourusername"
  66. set :password, "yourpassword" # if not using github
  67. set :deploy_via, :copy # if not using github
  68.  
  69. # Install shared rails stack to slicehost using deprec
  70. cap deprec:rails:install_stack
  71.  
  72. # Install shared database on slicehost.
  73. # WARNING! Don't run the following command if you
  74. # are using a shared database server that has already
  75. # been installed.
  76. cap deprec:db:install
  77.  
  78. # Modify file 'config/database.yml'
  79. production:
  80. adapter: mysql
  81. database: yourappname_production
  82. username: root
  83. password:
  84. host: localhost
  85.  
  86. # Publish changes to git
  87. git add .
  88. git commit -m "Updated configuration"
  89.  
  90. # Create mysql production database:
  91. mysqladmin -u root create yourappname_production # run on slicehost server
  92.  
  93. # Install project to slicehost using capistrano
  94. cap deploy:setup # once to initialize project
  95. cap deploy
  96.  
  97. # Install gem dependencies (requires custom Capistrano task)
  98. cap deploy:gems
  99.  
  100. # Run migrations
  101. cap deploy:migrate
  102.  
  103. ## Routine
  104. # Commit changes to git
  105. git add .
  106. git commit -m "Updated configuration"
  107.  
  108. # Deploy changes to server
  109. cap deploy
  110.  
  111. # Deploy new migrations to server
  112. cap deploy:migrate
  113.  
  114. # Deploy new gem dependencies to server (requires custom Capistrano task)
  115. cap deploy:gems
  116.  
  117. # Run this on server to rollback schema
  118. rake RAILS_ENV=production db:rollback
  119.  
  120. ## Switch domain name
  121. vi 'config/deploy.rb'
  122. set :domain, "yourdomain.com"
  123. cap deploy:setup # When prompted, overwrite apache_vhost
  124.  
  125. ## Troubleshooting
  126. # Run gems on server
  127. ssh username@domainname
  128. sudo gem update
  129.  
  130. # Run script/console on server
  131. ssh username@domainname
  132. cd /opt/apps/yourappname/current
  133. script/console production
  134. u = User.find_by_login('admin')
  135. u.is_admin = true
  136. u.save
  137.  
  138. # View Rails production log
  139. tail -f /opt/apps/yourappname/current/log/production.log
  140.  
  141. # View Apache log files
  142. tail -f /var/log/apache2/error.log
Add Comment
Please, Sign In to add comment