File uploads in a Passenger-backed application fail

Overview A file upload initiated in an application written in Ruby, Node, or Python launched through Passenger will fail to upload. Thus far, the confirmed failure occurs in RefineryCMS with a generic undefined route message following upload. Cause It is a conflict between upload screening and Passenger, but the underlying cause is not clearly understood. Upload…

PostgreSQL gem install fails

Overview Attempting to install the Ruby gem “pg” or other PostgreSQL-dependent gems on v6+ platforms fail with a similar sample response: Can’t find the PostgreSQL client library (libpq) *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You…

Write permission error when installing gems

Overview On newer v6+ platforms with support for multiple Ruby interpreters, installing a gem may fail resulting in a similar error message: [user@sol ~]$ gem install –no-rdoc –no-ri passenger rails Fetching: passenger-5.0.6.gem (100%) ERROR: While executing gem … (Gem::FilePermissionError) You don’t have write permissions for the /.socket/ruby/gems/ruby-2.1.2 directory. Cause The environment variable GEM_HOME is not configured…

Passenger application layout

Overview All Passenger applications require a compatible filesystem layout to launch and manage a Passenger-backed application. A layout consists of 4 features: Startup file Passenger loads this file to start the application Startup file names differ by application type (Python, Ruby, Node.js, Meteor) Document root folder called public/ all static content goes here (images, JavaScript, CSS) Apache configuration…

Disabling Passenger built-in error handler

Overview Passenger provides a user-friendly, on-screen error handler to assist debugging a Python/Ruby/Node.js application. During production, however, this may result in unnecessary and possibly dangerous information disclosure. You can turn off Passenger’s built-in logger and use Apache’s generic error handler by adding the following line to your .htaccess file located within the public/ folder of your app:…

Restarting Passenger processes

Overview An application launched by Passenger may be restarted by creating a file in tmp/ (NB: not /tmp) within the application root directory, usually one level down from public/. Create a file under tmp/ named restart.txt to restart the application once. A restart will happen within 2 minutes. To restart an application on every request, very useful for…

Changing Ruby versions

Overview Newer hosting platforms, v6+, support multiple Ruby versions through rvm. This enables you to run multiple versions of Rack and Rails using any available Ruby interpreters. Currently, versions 1.8 to 2.2 are supported. Important: Avoid using 1.8, except to shim an older application with an intent to upgrade. 1.8 is deprecated and contains several…