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 をはじめよう (d184)

目次 - Perl Index


Theme



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

今回は、「 mod_perl Home / The mod_perl Web Site / Documentation / mod_perl 2.0 Documentation / User's guide / Part I: Introduction / Getting Your Feet Wet with mod_perl 」を翻訳して確認します。

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






mod_perl をはじめよう : Getting Your Feet Wet with mod_perl




説明 : Description



This chapter gives you the bare minimum information to get you started with mod_perl 2.0. For most people it's sufficient to get going.

このチャプタはあなたが mod_perl 2.0 でスタートするための最小限の情報をあなたに与えます。それはほとんどの人がはじめるには十分です。


インストール : Installation



If you are a Win32 user, please refer to the Win32 installation document.

もしあなたが Win32 ユーザなら, Win32 installation document を参照してください。

First, download the mod_perl 2.0 source.

はじめに, mod_perl 2.0 ソースをダウンロードします。

Before installing mod_perl, you need to check that you have the mod_perl 2.0 prerequisites installed. Apache and the right Perl version have to be built and installed before you can proceed with building mod_perl.

mod_perl をインストールする前に, あなたは mod_perl 2.0 prerequisites (前提要件) をあなたがインストールしてあるかをチェックする必要があります。あなたは mod_perl のビルドに進む前に Apache と正しい Perl バージョンをビルドしてインストールしなければなりません。

In this chapter we assume that httpd and all helper files were installed under $HOME/httpd/prefork, if your distribution doesn't install all the files under the same tree, please refer to the complete installation instructions.

このチャプタで私たちは httpd とすべてのヘルパファイルが $HOME/httpd/prefork の下にインストールされると想定しています, もしあなたのディストリビューションが全てのファイルを同じツリーにインストールしないなら, 完全なインストール説明書を参照してください。

Now, configure mod_perl:

では, mod_perl を構成します:

% tar -xvzf mod_perl-2.x.xx.tar.gz
% cd modperl-2.0
% perl Makefile.PL MP_APXS=$HOME/httpd/prefork/bin/apxs

where MP_APXS is the full path to the apxs executable, normally found in the same directory as the httpd executable, but could be put in a different path as well.

MP_APXS は apxs 実行ファイルへのフルパスで, 普通は httpd 実行ファイルと同じディレクトリですが, 異なるパスに置いてもかまいません。

Finally, build, test and install mod_perl:

最後に, mod_perl をビルド, テストそれからインストールします:

% make && make test && make install

Become root before doing make install if installing system-wide.

システムワイドでインストールする場合は make install の前に root になります。

If something goes wrong or you need to enable optional features please refer to the complete installation instructions.

もしなにかうまく行かなかったりあなたがオプショナルな機能を有効にしたい場合は the complete installation instructions を参照してください。


構成 : Configuration



If you are a Win32 user, please refer to the Win32 configuration document.

もしあなたが Win32 ユーザなら, Win32 configuration documentを参照してください。

Enable mod_perl built as DSO, by adding to httpd.conf:

httpd.conf に追加することで, mod_perl を DSO として有効化します:

LoadModule perl_module modules/mod_perl.so


There are many other configuration options which you can find in the configuration manual.

configuration manual であなたが見つけられる構成オプションが他に多くあります。

If you want to run mod_perl 1.0 code on mod_perl 2.0 server enable the compatibility layer:

もしあなたが互換レイヤを有効化した mod_perl 2.0 サーバで mod_perl 1.0 コードを実行したいなら:

PerlModule Apache2::compat


For more information see: Migrating from mod_perl 1.0 to mod_perl 2.0.

詳細は参照します: Migrating from mod_perl 1.0 to mod_perl 2.0


サーバの起動とシャットダウン : Server Launch and Shutdown



Apache is normally launched with apachectl:

Apache は通常 apachectl で起動されます:

% $HOME/httpd/prefork/bin/apachectl start

and shut down with:

シャットダウンはこれで:

% $HOME/httpd/prefork/bin/apachectl stop

Check $HOME/httpd/prefork/logs/error_log to see that the server has started and it's a right one. It should say something similar to:

サーバがスタートしてそれが正しいものかを見るために $HOME/httpd/prefork/logs/error_log をチェックします。 それはこれと似たようなことをいうはずです:

[Fri Jul 22 09:39:55 2005] [notice] Apache/2.0.55-dev (Unix)
mod_ssl/2.0.55-dev OpenSSL/0.9.7e DAV/2 mod_perl/2.0.2-dev
Perl/v5.8.7 configured -- resuming normal operations



レジストリスクリプト : Registry Scripts



To enable registry scripts add the following to httpd.conf:

レジストリスクリプトを有効化するために httpd.conf に次を追加します:

Alias /perl/ /home/httpd/httpd-2.0/perl/
<Location /perl/>
SetHandler perl-script
PerlResponseHandler ModPerl::Registry
PerlOptions +ParseHeaders
Options +ExecCGI
Order allow,deny
Allow from all
</Location>

and now assuming that we have the following script:

では私たちは次のスクリプトをもっていると仮定します:

#!/usr/bin/perl
print "Content-type: text/plain\n\n";
print "mod_perl 2.0 rocks!\n";

saved in /home/httpd/httpd-2.0/perl/rock.pl. Make the script executable and readable by everybody:

/home/httpd/httpd-2.0/perl/rock.pl に保存します。スクリプトが誰でも実行 and 読み込みできるようにします:

% chmod a+rx /home/httpd/httpd-2.0/perl/rock.pl

Of course the path to the script should be readable by the server too. In the real world you probably want to have a tighter permissions, but for the purpose of testing that things are working this is just fine.

もちろんこのスクリプトへのパスはサーバからも読み込める必要があります。現実の世界であなたはよりタイトなパーミッションを必要とするかもしれませんが, それが動作しているかをテストする目的のためならちょうどよいです。

Now restart the server and issue a request to http://localhost/perl/rock.pl and you should get the response:

いまサーバをリスタートして http://localhost/perl/rock.pl にリクエストを発行するとあなたはレスポンスを得られるはずです:

mod_perl 2.0 rocks!


If that didn't work check the error_log file.

もしそれが動作しないなら error_log ファイルをチェックしてください。

For more information on the registry scripts refer to the ModPerl::Registry manpage. (XXX: one day there will a tutorial on registry, should port it from 1.0's docs).

レジストリスクリプトでのより多くの情報は ModPerl::Registry man ページを参照します。(XXX: そのうちレジストリでのチュートリアルを, 1.0 のドキュメントからポートしなければ)。


ハンドラモジュール : Handler Modules



Finally check that you can run mod_perl handlers. Let's write a response handler similar to the registry script from the previous section:

最後にあなたが mod_perl ハンドラを実行できることをチェックします. 前のセクションのレジストリスクリプトに似たレスポンスハンドラを書いてみましょう:

#file:MyApache2/Rocks.pm
#----------------------
package MyApache2::Rocks;

use strict;
use warnings;

use Apache2::RequestRec ();
use Apache2::RequestIO ();

use Apache2::Const -compile => qw(OK);

sub handler {
my $r = shift;

$r->content_type('type/plain');
print "mod_perl 2.0 rocks!\n";

return Apache2::Const::OK;
}
1;

Save the code in the file MyApache2/Rocks.pm, somewhere where mod_perl can find it. For example let's put it under /home/httpd/httpd-2.0/perl/MyApache2/Rocks.pm, and we tell mod_perl that /home/httpd/httpd-2.0/perl/ is in @INC, via a startup file which includes just:

どこか mod_perl が見つけられる場所の, ファイル MyApache2/Rocks.pm にコードを保存します。例えば /home/httpd/httpd-2.0/perl/MyApache2/Rocks.pm において, 私たちは次のようなスタートアップファイル (# おそらくファイル名を startup.pl とする) を介して /home/httpd/httpd-2.0/perl/ が @INC の中であることを mod_perl に伝えます:

use lib qw(/home/httpd/httpd-2.0/perl);
1;

and loaded from httpd.conf:

そうして httpd.conf から読み込みます:

PerlRequire /home/httpd/httpd-2.0/perl/startup.pl

Now we can configure our module in httpd.conf:

これで私たちは私たちのモジュールを httpd.conf の中で構成します:

<Location /rocks>
SetHandler perl-script
PerlResponseHandler MyApache2::Rocks
</Location>

Now restart the server and issue a request to http://localhost/rocks and you should get the response:

いまサーバをリスタートして http://localhost/roks へのリクエストを発行するとあなたはレスポンスを得られるはずです:

mod_perl 2.0 rocks!

If that didn't work check the error_log file.

もしそれが機能しないなら error_log ファイルをチェックしてください。


トラブルシューティング : Troubleshooting



If after reading the complete installation and configuration chapters you are still having problems, take a look at the troubleshooting sections. If the problem persist, please report them using the following guidelines.

もし installationconfiguration chapters を読み終えてもあなたがまだ問題をもっているなら, トラブルシューティングセクションを見てみてください. もし問題があり続けるなら, following guidelines を使ってそれをリポートしてください。


メンテナ : Maintainers



Maintainer is the person(s) you should contact with updates, corrections and patches.

メンテナはあなたがアップデート, 修正やパッチで連絡するとよい人々です。

  • Stas Bekman[http://stason.org/]




作者 : Authors



  • Stas Bekman[http://stason.org/]


Only the major authors are listed above. For contributors see the Changes file.

主要な作者のみ上にリストされています。コントリビュータは Changes ファイルを参照します。


NEXT



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


参考情報は書籍「 続・初めての 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 ▲