Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. How to Deploy Rails with:
  2. Ubuntu 16.04/Apache/Passenger/Rbenv/Ruby 2.4.1/Rails 5.1.1
  3.  
  4. Assuming Apache is already installed.
  5.  
  6. git clone gitlabrepo /var/www/html/rail/myapp
  7.  
  8. cd /var/www/html/rail/myapp
  9.  
  10. Assume that you're using Rbenv
  11.  
  12. rbenv version
  13.  
  14. rbenv local 2.4.1
  15.  
  16. rbenv global 2.4.1
  17.  
  18. 2.4.1 (set by /home/deploy/.rbenv/version)
  19.  
  20. deploy should have sudo rights. Capistrano
  21.  
  22. bundle exec bundle install
  23.  
  24. yarn install
  25.  
  26. bundle exec rails c
  27. bundle exec rails s RAILS_ENV=production
  28.  
  29. rails c
  30. rails s
  31. Its going to throw an error.
  32.  
  33. bundle exec rails db:migrate RAILS_ENV=production
  34.  
  35. gem 'dotenv-rails', .env
  36.  
  37. bundle exec rails assets:precompile
  38.  
  39. bundle exec rails db:seed RAILS_ENV=production
  40.  
  41. Apache
  42.  
  43. log/production.log
  44.  
  45. cd ~ (deploy)
  46. gem install passenger
  47.  
  48. passenger-config validate-install
  49.  
  50. apt install libapache2-mod-passenger
  51. tied to System Ruby
  52. Conflict rbenv 2.4.1 that I want to use
  53.  
  54. passenger-install-apache2-module
  55.  
  56. /etc/apache2/mods-available/passenger-rbenv.conf
  57. <IfModule mod_passenger.c>
  58. PassengerRoot /home/deploy/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/passenger-5.1.5
  59. PassengerDefaultRuby /home/deploy/.rbenv/versions/2.4.1/bin/ruby
  60. </IfModule>
  61.  
  62.  
  63. /etc/apache2/mods-available/passenger-rbenv.load
  64. LoadModule passenger_module /home/deploy/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/passenger-5.1.5/buildout/apache2/mod_passenger.so
  65.  
  66. a2enmod passenger-rbenv
  67.  
  68. service apache2 reload
  69.  
  70. That's it!
  71.  
  72. Forgot this in the video
  73.  
  74. <VirtualHost *:80>
  75. ServerName mydomain.com
  76. ServerAdmin root@localhost
  77. DocumentRoot /var/www/html/rails/myapp/public
  78. # RailsEnv development
  79. RailsEnv production
  80. ErrorLog ${APACHE_LOG_DIR}/error.log
  81. CustomLog ${APACHE_LOG_DIR}/access.log combined
  82. <Directory "/var/www/html/rails/myapp/public">
  83. PassengerRuby /home/deploy/.rbenv/versions/2.4.1/bin/ruby
  84. Options FollowSymLinks
  85. Require all granted
  86. </Directory>
  87. </VirtualHost>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement