Posted by ant
January 9th, 2009
Filed in Rails, Sysadmin
Setup Phusion Passenger (mod_rails) Apache module
sudo gem install passenger- copy the snippet from the terminal and into a file called
/etc/apache2/other/passenger.conf - Restart Apache –
sudo apachectl restart
Install Passenger PreferencePane
This makes it really easy to create hosts for your Rails applications and configure mod_rails in System Preferences.- Download Passenger PreferencePane
- Double click to install, have a play in System Preferences.
Install Upload Progress Apache module
git clone http://github.com/drogus/apache-upload-progress-module.gitcd apache-upload-progress-modulesudo apxs -c -Wc,-arch -Wc,i386 -Wl,-arch -Wl,i386 -i -a mod_upload_progress.c- Change the architecture string (i386) if yours is different
- This installs and enables the module in
/etc/apache2/httpd.conf
/etc/apache2/passenger_pane_vhosts. To enable upload progress for a site edit the .conf file appropriate for your site and insert the below snippet just before the </VirtualHost> line.
<IfModule upload_progress_module>
<Location />
# enable the tracking of uploads anywhere down from /
TrackUploads On
</Location>
<Location /progress>
# progress JSON will appear at /progress
ReportUploads On
</Location>
</IfModule>
Reconfigure Passenger PreferencePane to insert upload_module configuration
The application I’m currently developing requires upload progress and Apache needs to be able to follow symbolic links as I have certain assets stored outside of the main Rails application. The default Passenger PreferencePane configuration does not include these options.
I’ve updated the file that creates this configuration in a forked github repository. Dependent on where you installed the PreferencePane this file will either be in
~/Library/PreferencePanes/Passenger.prefPane/Contents/Resources– Installed only for your user- or
/Library/PreferencePanes/Passenger.prefPane/Contents/Resources– Installed for all users
Download PassengerApplication.rb and copy this file and the above configuration will be created.
Thoughtbot Paperclip
Paperclip is a fantastic file attachment plugin. It just uses ImageMagick to do it’s image processing. As long as the executables are in your path image scaling just works. It’s a whole load easier than configuring RMagick.
However, none of my images were rescaling and were dumping a strange error saying that Paperclip couldn’t determine the type of my file. I spent an hour trying to work out what the problem was, then I realised… The ImageMagick commands weren’t in the path for Apache. I tried various things to get this working, but tracked it down to a setting that can be put in one of your environment files.
Paperclip.options[:command_path] = "/opt/local/bin"
A quick restart of Rails later and it’s all working. This is what Paperclip was chucking out to my the development log:
[paperclip] An error was received while processing: #<Paperclip::NotIdentifiedByImageMagickError: /tmp/stream.637.0 is not recognized by the 'identify' command.>
Blog uses Mephisto
Design from OSWD
by dreamLogic

Leave a Reply ☆