Skip to content

Instantly share code, notes, and snippets.

@mba811
Created April 15, 2015 14:09
Show Gist options
  • Select an option

  • Save mba811/e8ab5b808200d178be4a to your computer and use it in GitHub Desktop.

Select an option

Save mba811/e8ab5b808200d178be4a to your computer and use it in GitHub Desktop.
So now we have PHP 5.4 with php-cgi installed. We can now setup our PHP site using Pow! All we have to do is create our config.ru
require 'rack'
require 'rack-legacy'
require 'rack-rewrite'
INDEXES = [ 'index.html' , 'index.php' , 'index.cgi' ]
ENV [ 'SERVER_PROTOCOL' ] = "HTTP/1.1"
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
end
end
rack_env [ 'PATH_INFO' ]
}
end
use Rack : :Legacy :: Php , Dir . getwd , '/usr/local/bin/php-cgi'
use Rack : :Legacy :: Cgi , Dir . getwd
run Rack : :File . new Dir . getwd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment