For faster navigation, this Iframe is preloading the Wikiwand page for PSGI.

PSGI

PSGI(Perl Web Server Gateway Interface)は、プログラミング言語Perlで使われる、WebアプリケーションとWebサーバを接続するインタフェースの1つであり、PerlにおけるWebアプリケーション用標準インタフェースとして使われることが意図されている。

動機および概要

[編集]

Perlスクリプトは、実行ファイル形式またはモジュール形式を用いてウェブアプリケーションとして実行できる。そのための枠組みの例として、CGI, FastCGI, SpeedyCGI, mod_perl, ISAPIなどが従来から存在する。これらのうちCGIが最も古典的でシンプルな実行方法として知られているが、クライアントからのリクエストのたびにプロセスの起動・破棄を行うため、サーバへの負担が大きく、ユーザへのレスポンスにも時間がかかる。また、このような起動形態ではデータベースとの接続といった必要な初期化も毎回行わなければならない。これらの問題を解決するために、FastCGI, SpeedyCGI, mod_perlなどが考案された。これらの環境では、Webアプリケーションプロセスを起動したままにして、リクエスト毎にこのプロセスがWebサーバと何らかのインタフェースで通信することで、プロセス起動や各種の初期化にかかるオーバーヘッドを排除している。しかしながら、これらの実行環境 (FastCGI, mod_perl, etc.) はそれぞれインタフェイスが異なるため、ウェブアプリケーションフレームワークごとに、それらの差異を吸収するためのコードが繰り返し再発明されていた。

この問題を解決すべく、宮川達彦氏を主導として、PythonWSGIRubyのRackから着想を得た、PSGIというウェブアプリケーション用の規格が策定された[1]。また、同時にPSGIのリファレンス実装であるPlackも発表された。PlackはCPANからダウンロードできる。PSGIの登場と普及により、具体的な実行環境を意識することなくウェブアプリケーションを作成できるようになった。2010年現在では、ほとんどのPerl製WebアプリケーションフレームワークがPSGIに対応している。

PSGIアプリケーションの例

[編集]

以下は、最も単純なPSGIアプリケーションの例である:

my $app = sub {
    return [200, ['Content-Type' => 'text/plain'], ["hello, world\n"]];
}

これをPSGIサーバの1つであるPlackで実行するには、hello.psgiとして保存して、コマンドラインシェルでplackup hello.psgiを実行すればよい。

PSGIに対応しているWebフレームワーク

[編集]

実行環境

[編集]

具体的にどの実行環境を使用するかはオペレーティングシステムやウェブサーバによって異なるが、次のような利用方法がある。

UNIX
Apache
  • CGI
  • FastCGI
  • SpeedyCGI
  • mod_perl
  • uWSGI
lighttpd
  • CGI
  • FastCGI
Nginx
  • uWSGI
  • FastCGI
Windows
IIS
  • CGI
  • ISAPI
Apache
  • CGI
  • FastCGI
  • SpeedyCGI
  • mod_perl
  • ISAPI
AN HTTPD
  • CGI
  • ISAPI

脚注

[編集]
  1. ^ http://gihyo.jp/news/report/01/yapcasia2009/0001 YAPC::Asia Tokyo 2009 スペシャルレポート
{{bottomLinkPreText}} {{bottomLinkText}}
PSGI
Listen to this article

This browser is not supported by Wikiwand :(
Wikiwand requires a browser with modern capabilities in order to provide you with the best reading experience.
Please download and use one of the following browsers:

This article was just edited, click to reload
This article has been deleted on Wikipedia (Why?)

Back to homepage

Please click Add in the dialog above
Please click Allow in the top-left corner,
then click Install Now in the dialog
Please click Open in the download dialog,
then click Install
Please click the "Downloads" icon in the Safari toolbar, open the first download in the list,
then click Install
{{::$root.activation.text}}

Install Wikiwand

Install on Chrome Install on Firefox
Don't forget to rate us

Tell your friends about Wikiwand!

Gmail Facebook Twitter Link

Enjoying Wikiwand?

Tell your friends and spread the love:
Share on Gmail Share on Facebook Share on Twitter Share on Buffer

Our magic isn't perfect

You can help our automatic cover photo selection by reporting an unsuitable photo.

This photo is visually disturbing This photo is not a good choice

Thank you for helping!


Your input will affect cover photo selection, along with input from other users.

X

Get ready for Wikiwand 2.0 🎉! the new version arrives on September 1st! Don't want to wait?