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.
- ssh root@nn.nn.nn.nn
- adduser mike
- logout
- ssh mike@nn.nn.nn.nn
- started mysql via Webmin control panel
- changed mysql root user password to DBPassword via Webmin control panel
- set up mike as a full admin using sudo by using visudo
- sudo adduser appuser
- mysql -u root -p
- CREATE DATABASE appproduction;
- GRANT ALL PRIVILEGES ON appproduction.* TO ‘appuser’@’localhost’ IDENTIFIED BY ‘apppassword’ WITH GRANT OPTION;
- quit; get out of mysql
- used Webmin to set mysql to listen on any
- sudo apt-get install libopenssl-ruby1.8 Without this step, recent Rails won’t run properly on Ubuntu or Debian
- mkdir /Library
- cd /Library
- sudo mkdir Rails -p -m 777 I like to keep my Rails apps in /Library/Rails. Your mileage may vary.
- changed server info in deploy.rb to point to the production server
- (on development machine) cap setup
- sudo gem install—include-dependencies mongrel_cluster
- (on development machine) cap deploy
- cd /Library/Rails/app/current
- rake db:migrate RAILS_ENV=production
- cd /etc/apache2/sites-enabled
- sudo nano 000-default edited this to basically match my staging version
- sudo a2enmod proxy_balancer
- sudo a2enmod proxy_http
- sudo a2enmod rewrite
- sudo /etc/init.d/apache2 force-reload
- sudo /etc/init.d/apache2 restart
- used Webmin control panel to set mysql to start at boot
- sudo ln -s /usr/lib/ruby/gems/1.8/gems/mongrel_cluster-0.2.1/resources/mongrel_cluster /etc/init.d/mongrel_cluster
- sudo chmod +x /etc/init.d/mongrel_cluster
- sudo mkdir /etc/mongrel_cluster
- sudo ln -s /Libray/Rails/app/current/config/mongrel_cluster.yml /etc/mongrel_cluster/nrafh.yml
- used Webmin to set mongrel_cluster to start at boot time