Perl mp2 翻訳 mod_perl とは何か ? (d180)

セラ (perlackline)

2021年01月22日 13:08

目次 - Perl Index


Theme



Perl について、復習を兼ねて断片的な情報を掲載して行く連載その d180 回。

今回は、「 mod_perl Home / The mod_perl Web Site / What is mod_perl? 」を翻訳して確認します。

正確な内容は 原文 を確認してください。誤解や誤訳がある場合はご指摘ください。





mod_perl とは何か? : What is mod_perl?



mod_perl は Apache と Perl の結婚です : mod_perl is the marriage of Apache and Perl



mod_perl brings together two of the most powerful and mature technologies available to the web professional today.

mod_perl は今日 web プロフェッショナルが利用できる最もパワフルで成熟したテクノロジをひとまとめにしたものです。

mp2 is mod_perl for the 2.x.x branch of the Apache HTTPD Server.
mp1 is mod_perl for the 1.3 branch of the Apache HTTPD Server.

mp2 は Apache HTTPD サーバ 2.x.x ブランチのための mod_perl です。
mp1 は Apache HTTPD サーバ 1.3 ブランチのための mod_perl です。

mp2 is fully compatible with httpd 2.0.x , and supports most of the 2.2.x feature set.

mp2 は httpd 2.0.x と完全な互換で, 2.2.x の機能セットのほとんどをサポートします。

mod_perl's future plans are to keep on supporting httpd as it evolves - that has always been the goal, and will always be so.

mod_perl の将来の計画は httpd の進化をサポートし続けることです - それは常にゴールであり, これからも同様です.

Simply install mod_perl and you have the full power of the Apache Web Server at your fingertips:

シンプルに mod_perl をインストールすれば Apache Web サーバのフルパワーがあなたの手元に:


既存の動的コンテンツを加速 : Accelerate your existing dynamic content



The standard Apache::Registry module can provide 100x speedups for your existing CGI scripts and reduce the load on your server at the same time. A few changes to the web server's config is all that is required to run your existing CGI scripts at lightning speed. more »

標準の Apache::Registry モジュールはあなたの既存の CGI スクリプトに 100x のスピードアップを提供し同時にあなたのサーバの負荷を軽減します。あなたの既存の CGI スクリプトを光速で実行するために必要なのは Web サーバの構成をすこし変更するだけです。more>>(https://perl.apache.org/start/tips/registry.html)

via: https://perl.apache.org/start/tips/registry.html

Running CGI scripts with mod_perl


Existing CGI scripts will run much faster under mod_perl. And converting existing CGI scripts to run under mod_perl is easy.

既存の CGI スクリプトは mod_perl のもとではるかに高速に走ります。または既存の CGI スクリプトを mod_perl のもとで実行するためのコンバートは簡単です。
For example, here's an existing CGI script called hello.cgi.

例えば, こちらが hello.cgi でコールされる既存の CGI スクリプトです。

file:hello.cgi
--------------
#!/usr/local/bin/perl -w
use strict;
use CGI;
my $q = CGI->new;
print $q->header,
$q->start_html,
$q->h1('Hello World!'),
$q->end_html;

This script can now be run as-is under Apache::Registry by using the following configuration in httpd.conf:

このスクリプトは httpd.conf で次の構成を使うことによりそのまま Apache::Registry のもとで実行できるようになります。

<Files hello.cgi>
SetHandler perl-script
PerlHandler Apache::Registry
Options ExecCGI
</Files>

That's basically it. Your scripts do need to be well coded, but there's even the Apache::PerlRun module to help with those "less clean" programs.

基本的にはこれだけです。あなたのスクリプトは良い感じにコード化する必要がありますが, "クリーンではない" プログラムをヘルプする Apache::PerlRun モジュールもあります。
So how much faster do scripts run under Apache::Registry? Obviously, it depends on the script, but the hello.cgi script above ran at 7.3 requests per second as a CGI script and 243.0 requests per second with Apache::Registry.

ではApache::Registry のもとでスクリプトを実行するとどのくらい速いのでしょうか ? 明らかに, それはスクリプトに依存しますが, 上記 hello.cgi スクリプトは CGI スクリプトとして毎秒 7.3 リクエスト Apache::Registry では毎秒 243.0 リクエストで実行されました。
For more information on running CGI scripts under mod_perl please see the CGI to mod_perl Porting section of The Guide.

mod_perl のもとで CGI スクリプトを実行するための詳細な情報は The Guide (# 2.0: https://perl.apache.org/docs/2.0/user/index.html, 1.0: https://perl.apache.org/docs/1.0/guide/index.html) の the CGI to mod_perl Porting section (# 1.0: https://perl.apache.org/docs/1.0/guide/porting.html) を参照してください。

>(https://perl.apache.org/start/tips/handler.html)

via: https://perl.apache.org/start/tips/handler.html

Creating a content handler with mod_perl 1.0


Handlers are simply perl subroutines called by the server at various stages of the HTTP request cycle. A content handler is a subroutine that is called by the response phase. Handlers, are typically created as a perl modules, separate files store in a library, and accessible via perl's @INC array.

ハンドラはHTTP リクエストサイクルのさまざまなステージでサーバによってコールされるシンプルな perl サブルーチンです。コンテンツハンドラはレスポンスフェーズにコールされるサブルーチンです。ハンドラは, 典型的にはライブラリに個々のファイルを格納し, perl の @INC 配列を介してアクセスできる, perl モジュールとして作成されます。
For example, here's an example that returns a greeting and the current local time.

例えば, こちらが挨拶と現在のローカルタイムをリターンする例です。

#file:My/Greeting.pm
#-------------------
package My::Greeting;
use strict;

use Apache::Constants qw(OK);

sub handler {
my $r = shift;
my $now = scalar localtime;
my $server_name = $r->server->server_hostname;

$r->send_http_header('text/plain');

print <<EOT;
Thanks for visiting $server_name.
The local time is $now.
EOT

return OK;
}
1; # modules must return true

Save the above as a file file in your perl library (e.g. My/Greeting.pm). Now, to return the above greeting when the URL /hello is visited on your server:

あなたの perl ライブラリファイル (e.g. My/Greeting.pm) に上記をファイルとして保存します。これで, あなたのサーバで URL /hello が訪れられたときに上記挨拶がリターンされるようにします:

<Location /hello>
SetHandler perl-script
PerlHandler My::Greeting
</Location>

For a more in-depth explanation of creating mod_perl handlers, and mod_perl in general, see the mod_perl Guide.

mod_perl ハンドラを作成と, 一般的な mod_perl のより深い説明は, mod_pel Guide (# 2.0: https://perl.apache.org/docs/2.0/user/index.html, 1.0: https://perl.apache.org/docs/1.0/guide/index.html) を参照してください。


関連記事