blog20100901

2013/08/20 - プログラミング言語 Perl にまつわる etc. - Perl monger
参考 : perldoc, perldoc.jp, search.cpan.org, perldoc.perl.org ...
「 初めての Perl 第 6 版 」(オライリー・ジャパン発行 ISBN978-4-87311-567-2) 」
「 続・初めての Perl 改訂版 」(オライリー・ジャパン発行 ISBN4-87311-305-9) 」
「 Effective Perl 第 2 版 」(翔泳社発行 ISBN978-4-7981-3981-4) 」 ... etc,.

Perl Perl_7 mod_perl 翻訳 Web Server

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

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) を参照してください。

<< back




Apache の一部となるカスタムモジュールを簡単に作成 : Easily create custom modules that become part of Apache



With mod_perl writing custom modules to extend and enhance Apache is a snap. Content handlers can be written in just a few lines of code and can be quickly integrated with existing modules specifically designed for use with mod_perl, or with modules freely available from the CPAN. more »

mod_perl では Apache を拡張したり強化するカスタムモジュールを書けます, 簡単に. コンテンツハンドラはたった数行のコードで書けますし, CPAN から自由に入手できるモジュール, 特に mod_perl で使うように設計された既存のモジュールとはクイックに統合できます。 more>>(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) を参照してください。

<< back




すべてのリクエストステージにアクセス可能 : Gain access to all request stages



mod_perl is not only about super fast content generation. With mod_perl all phases of the request cycle can be accessed and controlled. No other web acceleration product gives you this much control.

mod_perl は超速のコンテンツを生成するだけではありません。mod_perl ではリクエストサイクルのすべてのフェーズにアクセスしコントロールすることができます。あなたにこれほどのコントロールを与える web アクセラレーションプロダクトは他にありません。

Imagine the flexibility of rewriting URLs using Perl! Rewrite URLs based on the content of a directory structure, settings stored in a relational database, or the phase of the moon.

イメージしてください, Perl で URL をリライトすることのフレキシビリティを ! URL はディレクトリ構造の内容, リレーショナルデータベースに保存された設定, それから月の満ち欠けをベースにしてリライトします。

Write custom authentication and authorization modules to integrate with existing user databases or take advantage of the well-supported CPAN modules to extend the abilities of Apache. You can even create custom logging tailored to your site's specific needs. more »

既存のユーザデータベースと統合するためのカスタム認証と承認モジュールを書いたり, Apache の機能を拡張するためによくサポートされている CPAN モジュールを活用したりできます。あなたのサイト特有のニーズのためだけに仕立てたカスタムログすらも作成できます。 more>>(https://perl.apache.org/start/tips/favicon.html)

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


Using mod_perl to rewrite URLs


Anyone that's looked at web logs will quickly see the usefulness of this little mod_perl script. It catches all requests for favicon.ico and rewrites the request to point to a valid location. No more logs full of 404 errors.

web のログを見た人は誰でもこの小さな mod_perl スクリプトの有用性がすぐにわかります。これは favicon.ico へのすべてのリクエストをキャッチして有効なロケーションを指すためにリクエストをリライトします。404 エラーでいっぱいになったログはもういりません。
This example is adapted from the mod_perl Developer's Cookbook, chapter 12.

この例は mod_perl Developer's Cookbook の, チャプタ 12を翻案したものです。

#file:Cookbook/Favicon.pm
#------------------------
package Cookbook::Favicon;

use Apache::Constants qw(DECLINED);
use strict;

sub handler {
my $r = shift;

$r->uri('/images/favicon.ico')
if $r->uri =~ m!/favicon\.ico$!

return DECLINED;
}
1;

And configure in httpd.conf with:

それから httpd.conf をこれで構成します:

PerlModule Cookbook::Favicon
PerlTransHandler Cookbook::Favicon

Although this example could easily be accomplished with Apache's mod_rewrite module, this example demonstrates how easy it is to rewrite URLs programatically, using Perl.

この例は Apache の mod_rewrite モジュールで簡単に成すことができますが, この例はは URL をプログラム的に書きかえることがどのように簡単かをデモしています, Perl を使って。

<< back




Perl による Apache の構成 : Configure Apache with Perl



Perl can be used right in your httpd.conf file. Everything from virtual hosts to authentication settings can be configured via Perl. URL translation logic can be written with Perl for your complex or dynamic URL rewriting needs. Settings can be adjusted on a per-request basis and values passed from code in httpd.conf to your content generation modules. You can even generate complete HTTP output from the httpd.conf configuration file. more »

あなたの httpd.conf ファイルで Perl を正しく使えます。バーチャルホストから認証設定まですべて Perl を介して構成できます。複雑であったり動的であったりする URL 書き換えのニーズのための URL 変換ロジックを Perl で書けます。リクエストごとに設定を調整できますし値は httpd.conf からあなたのコンテンツ生成モジュールに渡されます。あなたは構成ファイル httpd.conf から完全な HTTP 出力ですら生成できてしまいます。more>>(https://perl.apache.org/start/tips/config.html)

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


Configure virtual hosts


With mod_perl, Perl code can be embedded directly in the Apache configuration file. Perl in httpd.conf is commonly used to dynamically configure Apache, but anything from URL translation to content generation can be accomplished directly in the configuration file within <Perl> sections.

mod_perl では, Perl コードを Apache 構成ファイルに直接埋め込むことができます。httpd.conf での Perl は通常 Apache の動的構成のために使われますが, URL トランスレーションからコンテンツ生成までのすべてをその構成ファイルの <Perl> セクションの中で直接成すことができます。
This example reads configuration settings from a text file and configures Apache's virtual hosts.

この例はテキストファイルから構成セッティングを読んで Apache のバーチャルホストを構成します。
The httpd.conf setup:

http.conf のセットアップです:

NameVirtualHost 192.168.0.1:80
<Perl>
my $config = "/etc/apache/vhosts.txt";
open HOSTS, $config or die "Failed to open $config: $!";

while (<HOSTS>) {
my %config;
my @params = qw/SeverName DocumentRoot ErrorLog TransferLog ServerAdmin/;
@config{ @params } = split /\t/;
$config{ Derectory }{ $config{DocumentRoot} } = { Allow => 'from all' };

push @{ $VirtualHost{'192.168.0.1:80'} }, \%config;
}
close HOSTS;
</Perl>

See The Guide for other examples of configuring Apache with mod_perl.

mod_perl での Apachce 構成の他の例は 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)を参照してください。

<< back




サードパーティモジュールのインストール : Install Third-party modules



Third-party modules give you application functionality such as sessions, passwords and database integration.

サードパーティモジュールはあなたにセッション, パスワードやデータベース統合などのアプリケーション機能を与えます。


アプリケーションフレームワーク : Application Frameworks



There are many high-level packages built on top of the mod_perl infrastructure to help you develop scalable and easily managed dynamic sites. All are well supported and maintain a loyal group of users.

スケーラブルで簡単に管理できる動的なサイトを開発するあなたをヘルプするために mod_perl のインフラ上で構築された多くのハイレベルなパッケージがあります。 すべてはよくサポートされていて熱心なユーザグループが維持されています。

You can select from a number of templating systems or application frameworks for use with mod_perl. See the mod_perl Products section for more information.

あなたは mod_perl で使うテンプレートシステムやアプリケーションフレームワークを多数の中から選択できます。詳細は mod_perl プロダクト (Application Servers and Toolkits based on mod_perl) セクションを参照してください。


Apache 2.X のサポート : Apache 2.X support



With mod_perl you can take advantage of the features of Apache 2.0. For example, custom protocol handlers can be written in Perl.

mod_perl で Apache 2.0 の機能を活用できます。例えば, Perl でカスタムプロトコルハンドラを書いたりできます。

Apache 2.0 is fully supported.
Most of Apache 2.2 is supported, and work toward full support is underway.

Apache 2.0 は完全にサポートされています。
Apache 2.2 のほとんどはサポートされていて, フルサポートに向けた作業が進行中です。


アクティブなサポートコミュニティ : Active Support Community



mod_perl has all the support anyone could ask for.

mod_perl には誰もが求める全てのサポートがあります。

Response time to questions posted on any of the mod_perl related lists is often measured in minutes. And with such a large installed base there's often someone that knows the answer to your specific question. In addition, a wealth of well maintained documentation is available online through this web site. For off-line, spend your time with excellent books about mod_perl. There's nothing like curling up in bed with a good book. Or someone that's read one.

mod_perl 関連のリスト (Mailing Lists) に投稿された質問へのレスポンスタイムは大抵は分単位で計測されます。 それからこのような大きなインストールベースではあなたの特定の質問への答えをだいたい誰が知っています。さらに、この web サイトを通じて良くメンテされた豊富なドキュメントをオンラインで利用可能です。オフラインでは、mod_perl に関する優れた本 (mod_perl and Related Books) とあなたの時間を過ごしてください。良い本とベッドで丸くなるほど良いことはありません。あるいはそれを読んだことのある人と。


Now, it's time to Get Your Feet Wet with mod_perl.

さあ、mod_perl で新しいこと (Getting Your Feet Wet) を始めましょう。


License



Like all Apache Software Foundation projects, mod_perl is licensed under The Apache License.

すべての Apache Software Foundation projects と同様に, mod_perl は The Apache License のもとでライセンスされています。


NEXT



次回は、「 mod_perl 」公式サイト (https://perl.apache.org/index.html) より「 Download 」を確認します。


参考情報は書籍「 続・初めての Perl 改訂版 」, 「 Effective Perl 第 2 版 」を中心に perldoc, Wikipedia および各 Web サイト。それと詳しい先輩。

目次 - Perl Index


























































同じカテゴリー(Perl)の記事
 Perl mp2 翻訳 Web コンテンツ圧縮の FAQ (d228) (2023-10-11 23:49)
 Perl mp2 翻訳 既知のブラウザのバグの回避策をいくつか (d227) (2023-05-26 15:41)
 Perl mp2 翻訳 Perl と Apache でのキュートなトリック (d226) (2023-05-19 17:05)
 Perl mp2 翻訳 テンプレートシステムの選択 (d225) (2022-08-15 22:23)
 Perl mp2 翻訳 大規模 E コマースサイトの構築 (d224) (2022-06-15 20:43)
 Perl mp2 翻訳 チュートリアル (d223) (2022-06-15 20:42)
上の画像に書かれている文字を入力して下さい
 
<ご注意>
書き込まれた内容は公開され、ブログの持ち主だけが削除できます。

Llama
リャマ
TI-DA
てぃーだブログ
プロフィール
セラ (perlackline)
セラ (perlackline)
QRコード
QRCODE
オーナーへメッセージ

PAGE TOP ▲