• Posted by Peter Haza
  • On August 14, 2008

  • Filed under Programming, Ruby / rails

  • 4 Comments

Phusion Passenger/modrails – Apache 2… not found – Could not find ‘apachectl’ or ‘apache2ctl’

Yesterday I was going to install Phusion Passenger also known as modrails to have another go at ruby on rails. Earlier I’ve been using Mongrel as web server, but I’m not very comfortable with it. But since modrails was released not too long ago, I figured I could give it whirl. The installation instructions were so short that I figured it would be a walk in the park.

I installed the gem,

sudo gem install passenger

and everything went just according to the plan. The next step was to run the installation script,

sudo passenger-install-apache2-module

and I was even greeted with this promising message:

This installer will guide you through the entire installation process. It shouldn’t take more than 3 minutes in total.

Here’s what you can expect from the installation process:

  1. The Apache 2 module will be installed for you.
  2. You’ll learn how to configure Apache.
  3. You’ll learn how to deploy a Ruby on Rails application.

Don’t worry if anything goes wrong. This installer will advise you on how to solve any problems.

Press Enter to continue, or Ctrl-C to abort.

“Shush you. Just take me to the solution, damn it!”

Problems

Ok, so even if something was to go wrong, the installer would help me.

Checking for required software…

  • GNU C++ compiler… found at /usr/bin/g++
  • Ruby development headers… found
  • OpenSSL support for Ruby… found
  • RubyGems… found
  • Rake… found at /usr/bin/rake
  • Apache 2… found at /usr/sbin/httpd
  • Apache 2 development headers… found at /usr/sbin/apxs
  • Apache Portable Runtime (APR) development headers… found at /Developer/SDKs/MacOSX10.5.sdk/usr/bin/apr-1-config
  • fastthread… found
  • rack… found

--------------------------------------------

--------------------------------------------

Compiling and installing Apache 2 module… cd /Users/peterhaza/Compile/passenger-2.0.3 rake clean apache2 (in /Users/peterhaza/Compile/passenger-2.0.3) rake aborted! Could not find ‘apachectl’ or ‘apache2ctl’. /Users/peterhaza/Compile/passenger-2.0.3/rakefile:35 (See full trace by running task with –trace)

--------------------------------------------

It looks like something went wrong

Please read our Users guide for troubleshooting tips:

/Users/peterhaza/Compile/passenger-2.0.3/doc/Users guide.html

If that doesn’t help, please use our support facilities at:

http://www.modrails.com/

We’ll do our best to help you.

LIES

Lies, lies and more lies. The installer didn’t help me, the user guide didn’t either, and the support facilities cost money. Damn it!

Well, so I set out to fix it myself. which behaved nicely and returned what I expected,

peterhaza@Farquaad passenger-2.0.3$ which apachectl
/usr/local/bin/apachectl

so it’s definitely there. I started to scan through the installer script, which was just a nice ruby script, and after trying to add the correct path at the top of the script (where it already adds some stuff to $PATH) and fail, I decided to dig a bit deeper.

Solution

In lib/passenger/platform_info.rb I found a method called self.determine_apache2_bindir. It does some fancy look-up stuff, but instead I just told it to return the path where I knew my apachectl was.

def self.determine_apache2_bindir
  "/usr/local/bin"
# if APXS2.nil?
#   return nil
# else
#   return `#{APXS2} -q BINDIR 2>/dev/null`.strip
# end
end

Voila! After this change, I ran the script again and would you know:

Lots of compiling messages…

The Apache 2 module was successfully installed.

Please edit your Apache configuration file, and add these lines:

LoadModule passenger_module /Users/peterhaza/Compile/passenger-2.0.3/ext/apache2/mod_passenger.so PassengerRoot /Users/peterhaza/Compile/passenger-2.0.3 PassengerRuby /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby

After you restart Apache, you are ready to deploy any number of Ruby on Rails applications on Apache, without any further Ruby on Rails-specific configuration!

Press ENTER to continue.

More messages…

So there you go!

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

4 comments

  1. Posted by einar stavleik 15th August, 2008 at 01:07 am |

    Did you report this bug (and fix) upstream?

  2. Posted by Peter Haza 15th August, 2008 at 06:03 pm |

    No, not yet. I wasn’t 100% sure if it was just my setup or not, because I’ve messed around quite a lot with the apache install, but I guess I could file a bug report.

  3. Posted by Jorge Falcão 27th October, 2008 at 04:05 pm |

    a better way: apt-get install apache2-threaded-dev

  4. Posted by Torkel Danielsson 7th January, 2009 at 06:01 am |

    I had the same problem but I came up with a different solution:

    The PATH was set to point first to /usr/local/bin and then to /usr/local/apache2/bin. I had an old copy of apxs in /usr/local/bin and this messed things up it seems..

    Reversing the order of the path so it looked at apach2 first solved it for me.

What do you think? Join the discussion...