Richard's Diary

Sunday, January 18, 2009

Rails Deployment with Passenger
  1. Install Apache2
    1. /etc/sysconfig/apache2
      1. configure modules loaded
      2. add APACHE_CONF_INCLUDE_FILES="httpd.conf.local"
    2. /etc/apache2/httpd.conf.local
      1. specify ip that apache listens on
      2. log rotation file:///usr/share/apache2/manual/logs.html.en
        apache2 continues to write to same log file unless the process is restarted. while one can do "apache2ctl graceful", it still causes unnecessary load when we can pipe logs.
      3. ErrorLog "|/usr/sbin/rotatelogs2 /var/log/apache2/error_log.%Y-%m-%d-%H_%M_%S 10M"
      4. CustomLog "|/usr/sbin/rotatelogs2 /var/log/apache2/access_log.%Y-%m-%d-%H_%M_%S 10M" combined
    3. vhosts.d/domain.conf
      1. specify ip of VirtualHost so that server is not dependent on DNS lookup
      2. specify domain of VirtualHost so people can't just assign domain to my ip and create bogus traffic that app can't respond to or if it can, will end up creating duplicate content
      3. RailsEnv development|production
      4. PassengerUseGlobalQueue on
      5. Override the default root Deny All for static assets by carving out the app/public folder excluding cgi and rb files and unwanted directories
    4. /etc/apache2/httpd.conf shows Options None, AllowOverride None as a Directory / (root) default so we don't need to "Options -Indexes"
    5. Default is "HostnameLookups off"
    6. configure access logs fields in /etc/apache2/mod_log_config.conf
      LogFormat "%a %t \"%r\" %>s %b %D %v \
      \"%{Referer}i\" \"%{User-Agent}i\"" combined
  2. Install Passenger
    1. add lines recommended by Passenger to httpd.conf.local
  3. Log naming and definition
    1. System /var/log/messages (iptables, ssh, sudo, command history) via logrotate /etc/logrotate.conf
    2. Rolling over Apache access and error logs (done)
    3. Rails log is DocumentRoot/log/#{environment}.log. I was able to change path to /var/log (done)
      1. Rails console prints to application server. It used to be mongrel console but now it's passenger console. Passenger prints everything to Apache error log and because it lives above any virtual host, it logs to the default Apache server error log. While initially this seemed like a problem, it's good practice to route the console log to the application log as development matures.
    4. Postgresql log by configuring postgresql.conf (done)
  4. Log management
    1. Run rotatelogs on system logs
    2. Run cron to rsync
    3. Run cron to delete the files edited over a week ago?

TODO

Notes

© 2010 Picky Ricky, Inc. originalblog