Fork me on GitHub

Kernow Soul

Ruby, Rails and JavaScript Consultant

Running Merb on a Shared Host Without Compiler Permissions

| Comments

I ran into a problem earlier today when testing a Merb application in a shared hosting environment running Phusion Passenger. Like most shared hosts access to compilers is not allowed for obvious security reasons, this causes a problem when trying to run a Merb app. Merb makes use of RubyInline which needs to compile a C application in your home folder before it can run so when the user you’re running Merb under doesn’t have permission to run C compilers you’ll get an error similar to:

1
sh: /usr/bin/gcc: Permission denied

The way to get around this is to have a privileged user compile the C application for you, then copy it to your users home folder. The easiest way to do this is to generate and run a Merb app as the root user:

1
2
3
merb-gen app tmp-merb
merb
Ctrl+C

Then copy the RubyInline C application to the users home folder:

1
cp -R /root/.ruby_inline /home/<username>

Make sure the file ownership is set correctly:

1
chown -R <username>:<username> /home/<username>/.ruby_inline

After this you should be able to run Merb as expected. If you’re still getting errors relating to file permissions after following the instructions above you’ll need to combine the fix from Vignet and put the .ruby_inline folder in a place accessible to both the apache user and the user running the Merb app, I’ve not tested this but it should work.

Comments