Production Rails Setup at RimuHosting

Posted by Mike
Liquid error: wrong number of arguments (5 for 2)

I’ve finished getting my first production Rails server up and running at RimuHosting . I kept reasonably careful notes along the way, and now I’m going to brain-dump them here, in part because I might need them again in the future, and in part because they might help someone else. Of course, there are so many variables that your setup very likely will not be a precise match for my setup, so use with appropriate caution.

We started with a MiroVPS3 (224MB) host with Debian Etch, the Webmin control panel, and RimuHosting’s own basic Rails stack preinstalled. That’s probably overkill for this little app, but the client wanted to be sure of plenty of breathing room. I’m targeting Apache + Mongrel for serving pages because that’s what I’ve been using in development and staging; production is not the time to experiment with a new-to-me server.

  1. ssh root@nn.nn.nn.nn
  2. adduser mike
  3. logout
  4. ssh mike@nn.nn.nn.nn
  5. started mysql via Webmin control panel
  6. changed mysql root user password to DBPassword via Webmin control panel
  7. set up mike as a full admin using sudo by using visudo
  8. sudo adduser appuser
  9. mysql -u root -p
  10. CREATE DATABASE appproduction;
  11. GRANT ALL PRIVILEGES ON appproduction.* TO ‘appuser’@’localhost’ IDENTIFIED BYapppasswordWITH GRANT OPTION;
  12. quit; get out of mysql
  13. used Webmin to set mysql to listen on any
  14. sudo apt-get install libopenssl-ruby1.8 Without this step, recent Rails won’t run properly on Ubuntu or Debian
  15. mkdir /Library
  16. cd /Library
  17. sudo mkdir Rails -p -m 777 I like to keep my Rails apps in /Library/Rails. Your mileage may vary.
  18. changed server info in deploy.rb to point to the production server
  19. (on development machine) cap setup
  20. sudo gem install—include-dependencies mongrel_cluster
  21. (on development machine) cap deploy
  22. cd /Library/Rails/app/current
  23. rake db:migrate RAILS_ENV=production
  24. cd /etc/apache2/sites-enabled
  25. sudo nano 000-default edited this to basically match my staging version
  26. sudo a2enmod proxy_balancer
  27. sudo a2enmod proxy_http
  28. sudo a2enmod rewrite
  29. sudo /etc/init.d/apache2 force-reload
  30. sudo /etc/init.d/apache2 restart
  31. used Webmin control panel to set mysql to start at boot
  32. sudo ln -s /usr/lib/ruby/gems/1.8/gems/mongrel_cluster-0.2.1/resources/mongrel_cluster /etc/init.d/mongrel_cluster
  33. sudo chmod +x /etc/init.d/mongrel_cluster
  34. sudo mkdir /etc/mongrel_cluster
  35. sudo ln -s /Libray/Rails/app/current/config/mongrel_cluster.yml /etc/mongrel_cluster/nrafh.yml
  36. used Webmin to set mongrel_cluster to start at boot time