Setting up Ruby CGI in Apache Setting up Ruby CGI in Apache ruby ruby

Setting up Ruby CGI in Apache


Few things to check:

  • is your file executable? You can make it executable by going chmod +x /path/to/file
  • did you output the correct Content-type?
  • is there a blank newline between your headers and your output?
  • did you restart Apache after setting the configuration?

If you did all that, it should work fine. I have this as my test.rb file:

#!/usr/bin/env rubyputs <<EOSContent-type: text/html<html><body>hi</body></html>EOS


I ran in to the same situation and was able to fix it by adding the following line after AddHandler:

Require all granted


Double check that mod_cgi is enabled; the default Yosemite http.conf has it disabled.