Last Updated: September 09, 2019
· michiels

Running PHP apps alongside Rails apps in Pow (

At Firmhouse, we do a little PHP development and a lot of Rails development. The last few weeks I was struggling to find an easy solution for running PHP (Especially WordPress) alongside my Rails apps in Pow.

I tried port forwarding to an internal PHP server and I certainly did not try falling back to Apache (bah!). Yesterday, I Googled and found the solution:

This article explains how to use the "rack-legacy" gem to call legacy CGI apps using Rack middleware. I just configured a WordPress "app" to use my local php 5.4 cgi installation by adding a


require 'rack'
require 'rack-legacy'
require 'rack-rewrite'

INDEXES = ['index.html','index.php', 'index.cgi']


use Rack::Rewrite do
  rewrite %r{(.*/$)}, lambda {|match, rack_env|
    INDEXES.each do |index|
      if File.exists?(File.join(Dir.getwd, rack_env['PATH_INFO'], index))
        return rack_env['PATH_INFO'] + index

use Rack::Legacy::Php, Dir.getwd, '/usr/local/bin/php-cgi'
use Rack::Legacy::Cgi, Dir.getwd
run Dir.getwd

And symlinking it to ~/.pow:

ln -s ~/Code/wordpress ~/.pow/wordpress

To access it at


1 Response
Add your response

what if I don't have '/usr/local/bin/php-cgi'

I ended up trying

over 1 year ago ·