Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Server
User Name
Linux - Server This forum is for the discussion of Linux Software used in a server related context.


  Search this Thread
Old 12-13-2010, 11:24 AM   #1
LQ Newbie
Registered: Dec 2009
Distribution: OpenSuse 11.3
Posts: 5

Rep: Reputation: 0
Question "/etc/init.d/apache2" start VS "apache2ctl start" with passenger module (ruby/rails)

Version: opensuse 11.3

I have a Sinatra application running on top of passenger module for Apache. Ruby 1.9.2

The application works if apache is started with "apache2ctl start", however, it doesn't when calling "service apache2 start".

The error comes from passenger:
Error message:
invalid byte sequence in US-ASCII
Exception class:

# File Line Location
0 /usr/lib/ruby/gems/1.9.1/gems/sinatra-1.1.0/lib/sinatra/base.rb 897 in `gsub'
1 /usr/lib/ruby/gems/1.9.1/gems/sinatra-1.1.0/lib/sinatra/base.rb 897 in `inline_templates='
2 /usr/lib/ruby/gems/1.9.1/gems/sinatra-1.1.0/lib/sinatra/base.rb 850 in `set'
3 /usr/lib/ruby/gems/1.9.1/gems/sinatra-1.1.0/lib/sinatra/base.rb 859 in `block in enable'
4 /usr/lib/ruby/gems/1.9.1/gems/sinatra-1.1.0/lib/sinatra/base.rb 859 in `each'
5 /usr/lib/ruby/gems/1.9.1/gems/sinatra-1.1.0/lib/sinatra/base.rb 859 in `enable'
I'm guessing somehow apache2ctl lets passenger->ruby interpreter know that Im working with UTF-8, where service apache2 start doesn't, however I don't manage it to work even explicitally setting LANG=en_US.UTF-8 in /etc/init.d/apache2.
Any ideas on how to make service apache2 start work like apache2ctl start?

Thanks in advance
Old 12-13-2010, 11:56 AM   #2
LQ Newbie
Registered: Dec 2009
Distribution: OpenSuse 11.3
Posts: 5

Original Poster
Rep: Reputation: 0
Solved. It seems the "/etc/init.d/apache2 start" method is not loading ruby with the encoding environment variables set properly.

For passenger to do it right we need a wrapper script /usr/local/bin/ruby_utf8:
exec /usr/local/bin/ruby -E utf-8:utf-8 "$@"
and then set Passenger to call that script instead of the ruby executable directly:
LoadModule passenger_module /usr/lib/ruby/gems/1.9.1/gems/passenger-3.0.1/ext/apache2/mod\
PassengerRoot /usr/lib/ruby/gems/1.9.1/gems/passenger-3.0.1
PassengerRuby /usr/local/bin/ruby_utf8
It seems that things are running fine now.


apache, initd, ruby, utf8

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Installing Ruby on Rails -- "gem update --system is disabled on Debian". bartonski Debian 2 08-23-2009 10:17 PM
LXer: "Ruby on Rails" comprehensively renovated LXer Syndicated Linux News 0 03-17-2009 04:10 PM
fdisk reports odd "Start "and "End" sectors on single partition eponymous Linux - Software 3 10-01-2007 04:41 PM
X Server broken. start w/ "INIT: ld "x" respawning too fast: disabled for 5 minutes&q tektone Linux - Hardware 5 07-25-2007 08:18 PM
LXer: RubyConf*MI, OSCON, and"Ruby for Rails" LXer Syndicated Linux News 0 08-02-2006 12:54 AM

All times are GMT -5. The time now is 06:49 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration