Results 1 to 2 of 2

Thread: service apache2 start VS apache2ctl start

  1. #1

    Question service apache2 start VS apache2ctl start

    Version: opensuse 11.3
    Apache/2.2.17

    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:
    ArgumentError

    Backtrace:
    # 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

  2. #2

    Default Re: service apache2 start VS apache2ctl start

    Solved. It seems the "service/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:
    #!/bin/bash
    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\
    _passenger.so
    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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •