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:80ServerName myserver DocumentRoot /var/www/apps/myapp/current/public Options FollowSymLinks AllowOverride None Order allow,deny Allow from all # Configure mongrel_clusterBalancerMember 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:80ServerName 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
