• This repository has been archived on 02/Dec/2018
  • Stars
    star
    127
  • Rank 282,790 (Top 6 %)
  • Language
    Ruby
  • Created almost 15 years ago
  • Updated almost 10 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Run legacy environments like CGI and PHP under any rack server.

Introduction

Rack Legacy tries to provide interaction with legacy environments like PHP and CGI while still getting the Rack portability so you don’t need a full Apache/lighttpd stack.

This software is currently BETA quality. Use at your own risk.

Purpose

The PRIMARY use case is while developing an application where Ruby is being used but there are also some legacy PHP or CGI that is running along-side your Ruby. This middleware allows you to do that development without the full Apache stack.

When you take the application to a production environment you can either leave this middleware in or use a full Apache stack to get more battle tested performance and security.

USAGE

Installation

gem install rack-legacy

Generic Rack Integration

Put the following in your rack stack:

require 'rack-legacy'
use Rack::Legacy::Php, 'public'

Rails Usage

In your Gemfile

gem 'rack-legacy'

In your application.rb:

config.middleware.insert_before \
  ActionDispatch::Static, Rack::Legacy::Php, Rails.public_path

Rails < 3 is not well supported. This is because Rack::Static (later turned into ActionDispatch::Static) is not in the Rails stack but instead processed in the stack that loads Rails prior to Rails running. This means you cannot insert any middleware before it. This software previously had some hacks to work around this but with the release of Rails 3 the hacks where not necessary and therefore removed.

If you still need to use rack-legacy on a Rails 2 app see version 0.1.5.

Legacy Modules

The above configuration just adds PHP support to your stack. That is just one of currently three modules available. The current modules are:

Rack::Legacy::Cgi

Provides support for executing any standard CGI script. It is important that script has the executable bit set.

Rack::Legacy::Php

Provides support for executing PHP scripts.

Rack::Legacy::Index

Provides support for running “index.php”, “index.cgi” or “index.html” when just a directory is specified in the request. You will want to install this module before the CGI or PHP ones.

An example rackup file that enables all modules (plus exception reporting and static file delivery) is:

require 'rack/showexceptions'
require 'rack-legacy'

use Rack::ShowExceptions
use Rack::Legacy::Index
use Rack::Legacy::Php
use Rack::Legacy::Cgi
run Rack::File.new Dir.getwd

Pure PHP/CGI

Got a project that is nothing but PHP or CGI? Run ‘rack_legacy` in the website root directory and it will start serving the files. It just executes the above example rackup file.

LICENSE

This is free and unencumbered software released into the public domain.

CREDIT

This gem was developed by Eric Anderson (pixelwareinc.com) partially via work done under Red Tusk Studios (redtusk.com) and Southern Web Group (www.southernwebgroup.com).