migrating from mongrel to passenger 1

Posted by chad on July 04, 2008

We migrated our main production server from mongrel to passenger today. Here are the things we learned from the process:

  • Don’t forget to set the apache APXS2 variable – the error won’t show up until you try to start apache after thinking that you successfully installed passenger. You will receive an error like this:
httpd: Syntax error on line 54 of /usr/local/apache2/conf/httpd.conf: API module structure 'passenger_module' in
file /usr/local/passenger/passenger-2.0.1/ext/apache2/mod_passenger.so is garbled - expected signature 41503232 but saw 41503230 -perhaps this is not an Apache module DSO, or was compiled for a different Apache version?
  • You can remove all of the rewrite rules from the apache conf file, but keep this part:
  
    Options FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
  
  • You’ll need to keep any apache rewrite rules related to displaying a ‘maintenance’ file.

What follows is the old mongrel apache configuration file, and the new one:

NameVirtualHost 10.x.x.x:80


  ServerName myserver

  DocumentRoot /var/www/apps/myapp/current/public

  
    Options FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
  

  # Configure mongrel_cluster
  
    BalancerMember http://127.0.0.1:8300
    BalancerMember http://127.0.0.1:8301
    BalancerMember http://127.0.0.1:8302
    BalancerMember http://127.0.0.1:8303
    BalancerMember http://127.0.0.1:8304
    BalancerMember http://127.0.0.1:8305
  

  RewriteEngine On

  # Prevent access to .svn directories
#  RewriteRule ^(.*/)?\.svn/ - [F,L]
#  ErrorDocument 403 "Access Forbidden"

  # Check for maintenance file and redirect all requests
  RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
  RewriteCond %{SCRIPT_FILENAME} !maintenance.html
  RewriteRule ^.*$ /system/maintenance.html [L]

  # Rewrite index to check for static
  RewriteRule ^/$ /index.html [QSA]

  # Rewrite to check for Rails cached page
  RewriteRule ^([^.]+)$ $1.html [QSA]

  # Redirect all non-static requests to cluster
  RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
  RewriteRule ^/(.*)$ balancer://myapp_cluster%{REQUEST_URI} [P,QSA,L]

  # Deflate
  AddOutputFilterByType DEFLATE text/html text/plain text/xml
  BrowserMatch ^Mozilla/4 gzip-only-text/html
  BrowserMatch ^Mozilla/4\.0[678] no-gzip
  BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

  ErrorLog /var/log/apache2/myapp.com-error_log
  CustomLog /var/log/apache2/myapp.com-access_log combined

To this with passenger apache configuration file:

NameVirtualHost 10.x.x.x:80

  ServerName myapp

  DocumentRoot /var/www/apps/myapp/current/public

  
    Options FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
  

  # Check for maintenance file and redirect all requests
  RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
  RewriteCond %{SCRIPT_FILENAME} !maintenance.html
  RewriteRule ^.*$ /system/maintenance.html [L]

ErrorLog /var/log/apache2/myapp.com-error_log
CustomLog /var/log/apache2/myapp.com-access_log combined

Trackbacks

Use this link to trackback from your own site.

Comments

Leave a response

  1. Eric Northam Wed, 20 Apr 2011 09:18:04 UTC

    Thanks Chad, I just ran into the APXS2 issue. Just a heads up I had to pass the export variable to sudo. Here’s the line I used.

    sudo sh -c “export APXS2=/usr/local/apache2/bin/apxs; passenger-install-apache2-module”

Comments