A mSQL and perl Web Server Mini HOWTO <author>Oliver Corff, <tt/corff@zedat.fu-berlin.de/ <date>v0.1, 17 September 1997 <trans>伊佐冶 哲, <tt/isaji@mxu.meshnet.or.jp/ <abstract> <!-- This Mini HOWTO, highly inspired by Michael Schilli's article <it>Gebunkert: Datenbankbedienung mit Perl und CGI</it>, published in the german computer magazine iX 8/1997, describes how to build a SQL client/server database using WWW and HTML for the user interface. --> このmini-HOWTOはユーザーインターフェースとしてWWWとHTMLを使った SQL クライアント/サーバー データベースの構築方法について書かれています。 ドイツコンピュータマガジン(german computer magazine)iX 8/1997 で出版され た&dquot;<it>Gebunkert: Datenbankbedienung mit Perl und CGI</it>(PerlとCGI を使ったデータバンクサービス)&dquot;というMichael Schilli氏の記事に触発され ています。 </abstract> <toc> <sect>このドキュメントについて <!-- About this Document --> <p> <sect1>対象読者 <!-- Intended Audience --> <p> <!-- Everybody who wants to install a web server database but does not know which software is necessary and how it is installed should benefit from reading this text. This text provides all information necessary to get a SQL database for a web server going; it does <em/not/ go into any detail of CGI programming, nor does it explain the SQL database language. Excellent books are available on both topics, and it is the intention of this text to provide a working platform based on which a user can then study CGI programming and SQL. --> Webサーバデータベースをインストールしたいけれど、必要なソフトウェアは何か、 どのようにインストールすればよいのかわからないといった人向けに書かれて います。またwebサーバを使ったSQLデータベースを入手するために必要な情報 も提供しています。CGIプログラミングやその詳細については詳しく調べてありま せんし、SQL言語についても説明はしていません。これらについて書かれた良書 がたくさんで出回っています。このドキュメントではユーザーがCGIプログラミング とSQLを学ぶことのできる場を提供します。 <p> <!-- For getting a small scale SQL system running (not the notorious example of a major airline booking system, or space mission management database) it will be sufficient to have the software described in this text and the documentation accompanying it. The user manual of msql (a database introduced in this text) provides sufficient information on SQL for building your own database. --> (悪名高い航空座席予約システムや宇宙飛行マネージメントデータベースではなく) 小さいスケールのSQLシステムを稼働させることに関してはこのテキストに書かれた ソフトウェアで十分ですし、ドキュメントはそれにそって書いています。 このテキストで紹介するデータベースmsql のユーザーマニュアルは各自のデータ ベースの構築法について詳しく情報を提供してくれています。 <p> <!-- The reader of this text should have a working knowledge of how to obtain files via <tt/ftp/ if he has no access to CD-ROMs, and a basic understanding of how to build binaries from sources. Anyway, all steps explained in this text were tested on a real life system and should also work on the reader's system. --> もしCD-ROMが使えない場合は、<tt/ftp/経由でファイルを入手する ための方法を知っておきましょう。またソースからバイナリを作るやりかたも 理解しておいて下さい。とにかくこのテキストで説明していることは実際稼働 しているシステム上でテストし、読者のシステム上でも動作するものと思います。 <sect1>このテキストで使われる表現 <!-- Conventions used in this text--> <p> <!-- A user command: --> ユーザーコマンド: <verb> # make install </verb> <!-- Screen output from a program: --> プログラムからの画面出力: <tscreen><verb> Program installed. Read README for details on how to start. </verb></tscreen> <!-- Sample code of a file: --> ファイルのサンプルコード: <code> # My comment char letter; </code> <sect>イントロダクション <p> <!-- It can be safely assumed that databases with a high volume of data or a complicated relational setup (like, perhaps, a lexical database for a living language) must be accessible to many users and operators at the same time. Ideally, it should be possible to use existing different hardware and software platforms that can be combined into the actual system. In order to reduce the implementation cost, only one system, the database server, needs to be powerful; the user stations typically just display data and accept user commands, but the processing is done on one machine only which led to the name client-server database. In addition, the user interface should be easy to maintain and should require as little as possible on the client side. --> 膨大なデータや(辞書データベースといった)複雑なリレーショナル設定の データベースは多くのユーザやオペレータが同時に使えるものでなくてはなりません。 理想的にはシステム的に接続されたさまざまなハード/ソフトウェアを使えるもの であるべきです。経費を節約するためにひとつのシステム、データベースサーバ はパワフルなものである必要があります。ユーザーステーションは一般的にデータ の表示とコマンドの実行をします。処理はクライアント-サーバデータベース にする1台のマシン上で行われます。 さらにユーザインターフェースの管理が容易でできるだけクライアント側への 負担がないものの方がよいでしょう。 <p> <!-- A system which meets these criteria can be built around the following items of protocols, concepts and software: --> 以上の基準(criteria)を満たすシステムは以下のプロトコル、概念、ソフトウェア アイテムを使って構築できます。 <descrip> <tag/Linux/ <!-- supplies the operating system. It is a stable Unix implementation providing true multi-user multi-tasking services with full network (TCP/IP e.~a.) support. Except from the actual media and transmission cost, it is available free of charge and comes in form of so-called distributions which usually include everything needed from the basic OS to text processing, scripting, software development, interface builders, etc. -->オペレーティングシステムです。マルチユーザ、マルチタスクを ネットワーク(TCP/IP)上で提供する安定したUNIXです。実際のメディア と通信コストを除けば全てがフリーです。基本OSからテキスト プロセッサ、スクリプト、ソフト開発、インターフェースビルダーなど 必要なもの全てがそろっています。 <tag/HTML/ <!-- is the Hypertext Markup Language used to build interfaces to network systems like Intranets and the WWW, the World Wide Web. HTML is very simple and can be produced with any ASCII-capable text editor. -->HTMLはインターネット、WWW(World Wide Web)といったネットワーク システムインターフェースを構築するためのHypertext Markup言語 (Language)です。 HTMLは簡単でASCIIテキストエディタで編集することができます。 <tag/Browsers/ <!-- are text-based (e.~g.~Lynx) or graphical (e.~g.~Mosaic, Netscape, Arena etc.) applications accepting, evaluating and displaying HTML documents. They are the only piece of software which is directly operated by the database user. Using browsers, it is possible to display various types of data (text, possibly images) and communicate with http servers (see next) on about every popular computer model for which a browser has been made available. -->ブラウザにはテキストベース(例えばLynx)あるいはグラフィカル(Mosaic, Netscape, Arenaなど)アプリケーションが使えます。HTMLドキュメントの読み込みと 表示をします。データベースユーザによって直接操作される唯一のソフト でもあります。ブラウザを使うことでテキスト、イメージといったさまざま なデータを表示できます。またブラウザが使えるさまざまなコンピュータ に対してhttpサーバで通信することができます。 <tag/http サーバ/<!-- provide access to the area of a host computer where data intended for public use in a network are stored. They understand the http protocol and procure the information the user requests. -->http サーバはネットワークで一般に使用されるデータがあるホストコンピュータへ のアクセスを提供します。httpプロトコルを理解し、ユーザが要求する 情報を渡します。 <tag/SQL/ <!-- Structured Query Language is a language for manipulating data in relational databases. It has a very simple grammar and is a standard with wide industry support. SQL-based databases have become the core of the classical client/server database concept. There are many famous SQL systems available, like Oracle, Informix etc., and then there is also msql which comes with a very low or even zero price tag if it is used in academical and educational environments. -->Structured Query Languageの略。関連データベースのデータを操作する 言語です。文法は簡単で広く商業的(wide industry)にもサポートされて います。SQLを基にしたデータベースは典型的なクライアント/サーバ の考えの中心(core)となるものです。多くのSQLシステムがあります。 有名なものではOracle, Informixなどで、低価格のものや学術的/教育的 な使用目的の場合は無料で入手できるようになりました。 (<bf/訳注:/SQL=データを蓄積(Query)する時の構造とその取り出し方を 定めている言語です。SQL標準化[日本では1987年JIS規格となり ました]によりDB言語の統一、異種DBMSとの互換性などの利点が あります) <tag/CGI/ <!-- Common Gateway Interface is the programming interface between the system holding the data (in our case an SQL-based system) and the network protocol (HTML, of course). CGIs can be built around many programming languages, but a particularly popular language is perl. -->CGI(Common Gateway Interface)はデータを蓄えてあるシステム(今回はSQL をベースとしたシステムです)とネットワークプロトコル(HTML)間の プログラミングインターフェースです。CGIは多くのプログラミング言語 で構築できますがもっともよく使われているのはperlです。 <tag/perl/ <!-- is an extremely powerful scripting language which combines all merits of C, various shell languages, and stream manipulation languages like awk and sed. Perl has a lot of modularized interfaces and can be used to control SQL databases, for example. -->Perlはきわめてパワフルなスクリプト言語です。C言語、シェル言語、 ストリーム操作言語(sed、awkなど)の長所を持っています。Perlには 多くのモジュラインターフェースがあり、SQLデータベースをコントロール することもできます。 </descrip> <sect>インストール過程 <!-- Installation Procedure --> <p> <sect1>必要なハードウェア <!-- Hardware Requirements --> <p> <!-- No general statement can be made about the hardware requirements of a database server. Too much depends on the expected number of users, the kind of application, the network load etc. In a small environment with only a few users and little network traffic a i486-equivalent machine with 16 MB of RAM can be completely sufficient. Linux, the operating system, is very efficient in terms of resources, and can supply enough horse-power for running a broad variety of applications at the same time. Of course, faster processors and more RAM mean more speed, but much more important than the processor is the amount of RAM. The more RAM the system has the less it is forced to swap memory intensive processes to disk in case a bottleneck occurs. --> データベースサーバで必要なハードウェアについて一般的なことは言えません。 予想されるユーザーの数、アプリケーションの種類、ネットワーク経路(network load)等に大きく依存しています。 2〜3人のユーザがいるだけでネットワークトラフィックも少ない最小な環境では RAM 16MB、i486程度のマシンで十分です。Linuxはリソースに関してはそれで 十分で、同時にさまざまなアプリケーションを起動するだけの馬力があります。 もちろんもっと速いプロセッサやRAMの増設をすればするほど高速化することもで きますが、プロセッサよりもRAMの容量の方が重要です。 RAMを増やせば増やすほど、障害を生じやすい集中的なメモリープロセスのディスク スワップが小さくなっていくのです。 <p> <!-- Given anything like 32 MB RAM and a PCI bus, searches and sorting operations can be done without much resorting to swap files etc., resulting in lightening fast speed. --> 32 MB RAM と PCIバスがあればスワップファイルなどを使わないで検索とソート を高速に行うことができます。 <p> <!-- The model installation described in this article was made on a IBM 686 (133Mhz) with 32 MB RAM and a 1.2 GB IDE hard disk. Assuming that the installation process starts from scratch, here is a list of the necessary steps. --> この文書で書かれているインストールは32 MB RAM、1.2 GB IDEハードディスクの IBM 686(133Mhz) で行っています。はじめからインストールするものとして以下、 必要な手順のリストを書きました。 <sect1>必要なソフトウェア <!-- Software Requirements --> <p> <!-- The software described in this article is available from the Internet or from CD-ROM. The following products were used: --> この文書で取り扱うソフトウェアはCD-ROMやインターネットから入手できるもの です。以下のものを使います: <itemize> <item> Red Hat Linux PowerTools:<!-- 6 CD's Complete Easy-to-Use Red Hat 4.2, Summer '97; alternatively from <tt>http://www.redhat.com</tt>; -->Red Hat Linux PowerTools:6 CD's Complete Easy-to-Use Red Hat 4.2, Summer '97;<tt>http://www.redhat.com</tt> から。 <item> msql SQLデータベースサーバ:<!-- it is now available in two versions. The versions have differences in the number of transactions they can handle, the administration interface, etc. The elder version, 1.0.16, is available from Sunsite mirrors. The ELF executable can be found at <tt>sunsite:apps/database/sql/msql-1.0.16</tt> or on CD-ROM (here: disc 4 of InfoMagic Linux Developer's Resource, 6-CD set, December 1996) or alternatively from the following URL: <tt>http://www.infomagic.com</tt>. -->現在2つのバージョンのものが入手できます。このバージョンの 違いは処理できる数、アドミニストレーションインターフェースの違いに 依っています。古い方のバージョンは1.0.16で、Sunsiteミラーサイトから 入手できます。ELFファイルは <tt>sunsite:apps/database/sql/msql-1.0.16</tt> やCDROM(disc 4 of InfoMagic Linux Developer's Resource, 6-CD set, December 1996)、 <tt>http://www.infomagic.com</tt>から入手します。 <!-- The newer version, 2.0.1, can be directly obtained from Hughes' homepage in Australia (<tt>http://www.hughes.com.au</tt>) or from numerous mirror sites around the world; -->新しいバージョンは2.0.1です。オーストラリアのHughe氏のホームページ (<tt>http://www.hughes.com.au</tt>)やその他ミラーサイトから入手できま す。 <item> CPANのperl:The Comprehensive Perl Archive Network. Walnut Creek CDROM, ISBN 1-57176-077-6, May 1997; <item> <!-- Michael Schilli's CGI example program from computer journal iX 8/1997, pages 150- -152, available via ftp from <tt>ftp.uni-paderborn.de:/doc/magazin/iX</tt>; --><tt>computer journal iX 8/1997, pages 150--152</tt>のMichael Schilli 氏によるCGIサンプルプログラム。ftpで入手 <tt>ftp.uni-paderborn.de:/doc/magazin/iX</tt>。 </itemize> <sect1>OSのインストール <!-- Installing the Operating System --> <p> <!-- Linux is installed in form of the Red Hat Linux Distribution 4.2. In order to install successfully, the machine must either have a DOS-accessible CD-ROM drive, a bootable CD-ROM drive, or else a boot disk must be made following the instructions on the Linux CD. --> 著者は<tt/Red Hat Linux Distribution 4.2/からLinuxをインストールしています。 ちゃんとインストールするために、マシンはDOSでアクセスできるCDROMドライブ/ ブート可能なCDROMドライブか、Linux CDの以下の設定を盛り込んだブートディスク のどちらかを持っているとよいでしょう。 <p> <!-- During installation the user has the choice to select and configure numerous software packages. It is convenient to select the following items now: --> インストールの途中でソフトウェアパッケージの選択と設定を行います。 以下のアイテムを選択しておいて下さい。 <itemize> <item> TCP/IP ネットワークサポート <item> http サーバ Apache <item> スクリプト言語perl <item> X Window System <item> Arena (グラフィカル)とLynx (テキストベース)ブラウザ </itemize> <!-- All these packages are provided with the Linux distribution. If you do not install these packages now you still have the chance to do this later with the assistance of glint, the graphical and intuitive software package installation manager. Be sure to be root when installing these packages. --> これらのパッケージはLinuxディストリビューションで配布されています。 もしすぐにこれらのパッケージをインストールしないなら、ソフトウェア パッケージにあるグラフィカルで直観的なインストールマネージャを使って後から インストールできます(<bf/訳注:/setupコマンドなどで)。 これらのパッケージをインストールする際はrootで作業をして下さい。 <p> <!-- It is beyond the scope of this article to describe the network installation and initialization procedure. Please consult the online (manpages, HTML, texinfo) and printed (Linux Bible, etc.~etc.) documentation. --> この文書ではネットワークインストールや初期設定の仕方は取り扱いません。 オンラインドキュメント(manページ、HTML、texinfo)や出版されている ドキュメント((Linux Bibleなどなど)を参照して下さい。 <p> <!-- The installation procedure of Red Hat is very mature and requires only little user attention besides the usual choices (like providing host names, etc.). Once the installation ends successfully, the system is basically ready to go. --> Red Hatのインストール方法は十分確立されていて、選択(ホスト名の指定など)を 普通に行うだけです。インストールが成功すれば、システムはすぐに稼働できます。 <p> <!-- Installing the X Window System is not mandatory for a pure server but it makes local access and testing much easier. The X installation procedure is done by any of several programs; XF86Setup offers the most extensive self-testing facilities and needs the least handling of hairy details (like video clock programming, etc.). The only requirement is that the software can detect the video adapter. A cheap accelerated graphics adapter (like Trio S64 based cards prior to S64UV+) usually works ``out of the box''. --> X Window Systemのインストールはサーバには必ずしも必要ではありませんが ローカルアクセスやテストが簡単になるので入れておくとよいでしょう。 Xのインストール方法はいくつかプログラムを使うことで行えます(XF86Setup は自己テストの機能(self-testing facilities)を装備していて、例えばビデオ クロックプログラミングなど難しい操作はほとんどありません)。必要なことは ソフトウェアがビデオアダプタを検出できるかどうかということだけです。 安価なアクセラレータグラフィックアダプタ(S64UV+の前身のTrio S64のような アダプタなど)は通常、特に何もしなくても(``out of the box'')動作します。 <p> <!-- At this point we assume that our system is up and running and that Apache, Perl and the X Window System have been successfully installed. We further assume that all standard structures like the file and directory structure are kept as they are defined in the installation. Last but not least we leave the host name as it is, and do at this moment accept the name <tt>localhost</tt>. We'll use this name for testing the installation; once the whole system works the true name can be added. Please note that the network setup also requires editing the files <tt>/etc/hosts</tt>, among others. Ideally this should be done with the administration tools provided to user root. --> ここでシステムに<tt/Apache, Perl, X Window System/がすでにインストールされて いるものとします。今後、ファイル/ディレクトリといった基本的なことはインストール 時のままとして話しを進めていきます。またホスト名は<tt>localhost</tt>とします。 このホスト名をインストールのテスト用に使います。全システムがちゃんと動作 したら適当な名前をつけます。<tt>/etc/hosts</tt>ファイルなどを編集する 必要があることもおぼえておいて下さい。理想的にはこれらはroot用の管理者 ツールを使って行うべきです。 <sect1>httpサーバ <!-- The http Server --> <p> <!-- The http server supplied with Linux is known as Apache to humans and as httpd to the system. The manpage (man httpd) explains how to install and start the http daemon (hence http<em/d/) but, as mentioned, if the installation went without problems then the server should be running. You can verify the directory tree: there must be a directory <tt>/home/httpd/</tt> with three subdirectories: <tt>../cgi-bin/</tt>, <tt>../html/</tt> and <tt>../icons/</tt>. In <tt>../html/</tt> there must be a file <tt>index.html</tt>. Later we will manipulate or replace this file by our own <tt>index.html</tt>. All configuration information is stored in<tt>/etc/httpd/conf/</tt>. The system is well preconfigured and does not need further setup provided the installation went without error. --> Linuxで使われるhttpサーバはApache(httpd)が有名です。 manページ(man httpd)でhttpデーモン(http<em/d/)のインストールと稼働の仕方 について説明しています。しかし問題なくインストールできているならすでにサーバは 稼働されています。ディレクトリを確認します:<tt>/home/httpd/</tt>以下3つ のサブディレクトリ<tt>../cgi-bin/</tt>、<tt>../html/</tt>、<tt>../icons/</tt> があります(訳注:RedHat以外のディストリビューションではディレクトリが若干 違うかもしれません)。<tt>../html/</tt>ディレクトリには<tt>index.html</tt> ファイルがあります。あとでこのファイルは各自のファイル<tt>index.html</tt>に 置き換えて下さい。設定の情報は<tt>/etc/httpd/conf/</tt>に蓄積されています。 システムが十分に設定されていて、特にエラーもなくインストールができたならこれ 以上は必要ありません。 <sect1>ブラウザ <!-- The Browsers --> <p> <!-- There are essentially three types of browsers available for Linux: pure text-based systems like Lynx, experimental and simple ones like Arena (free!) and commercial ones like Netscape (shareware!) with Java support. While Lynx and Arena come with Linux, Netscape must be procured from other sources. Netscape is available as a precombiled binary for Linux on ix86 architectures and will run ``out of the box'' as soon as the archive is unpacked. --> 基本的にLinux用のブラウザには3つのものがあります: <itemize> <item>Lynx:テキストベースのシステム。 <item>Arena(フリー):シンプルなブラウザ。実験的 <item>Netscape(シェア):Javaをサポートしています。 </itemize> LynxとArenaLinuxに附属していますが、Netscape はよそから入手しなければ なりませんix86アーキテクチャ上で動作するLinux用のものがバイナリファイルで 配布されています。アーカイブを展開すればすぐに(``out of the box'')実行でき ます。 <sect2>Lynxの設定 <!-- Configuring Lynx --> <p> <!-- Once Lynx is started it will look for a `default URL' which is usually not very meaningful if the system does not have permanent Internet access. In order to change the default URL (and lots of other configuration details) the system administrator should edit <tt>/usr/lib/lynx.cfg</tt>. The file is big, around 57000 bytes and contains occasionally contradicting information. It states its own home as <tt>/usr/local/lib/</tt>. Not far from top is a line beginning with <tt>STARTFILE</tt>. We replace this line by the following entry: <tt>STARTFILE:http://localhost</tt> and make sure that no spacing etc.~is inserted: --> Lynxは起動時にデフォルトURLを表示しようとします。これは常にインターネットに 接続していない場合にはちょっと厄介です。このデフォルトURLを変更する (また他の設定も変更する)ために、システム管理者は<tt>/usr/lib/lynx.cfg</tt> (<bf/訳注:/または<tt>/usr/local/lib/lynx.cfg</tt>など)ファイルを編集する必要が あります。この設定ファイルは約57,000バイトと大きく不必要な情報を含んでいるも のもあり、<tt>/usr/local/lib/</tt>ディレクトリをホームディレクトリとして記述 しています。 ファイルのはじめあたりに<tt>STARTFILE</tt>ではじまる行があるので、これを 以下のように変更します。 <code> # STARTFILE:http://www.nyu.edu/pages/wsn/subir/lynx.html # STARTFILE:http://lynx.browser.org/ STARTFILE:http://localhost </code> <!-- After saving the file, Lynx should now reveal our <tt>index.html</tt> document if started without arguments. --> ファイルを保存後、Lynxは引数なしで<tt>index.html</tt>ドキュメントを 表示するようになります。 <p> [訳注:&dquot;Lynxについて&dquot;<p> LynxはVer2.5あたりから特別なパッチなしで日本語が通るように なりました。以下のサイトを参照してみて下さい。 <itemize> <item>最新のLynxソース<htmlurl url="ftp://ftp2.cc.ukans.edu/pub/lynx/" name="ftp://ftp2.cc.ukans.edu/pub/lynx/"> <item>Lynxの日本語化について <htmlurl url="http://www.three-a.co.jp/~asada/lynx/" name="http://www.three-a.co.jp/˜asada/lynx/"> <item>Lynxとkterm。terminfoのバグ修正について <htmlurl url="http://www-nagao.kuee.kyoto-u.ac.jp/member/shimada/misc/lynx-kterm.html" name="http://www-nagao.kuee.kyoto-u.ac.jp/member/shimada/misc/lynx-kterm.html"> </itemize> ] <sect2>Arenaの設定 <!-- Configuring Arena --> <p> <!-- Arena first looks for its own default URL when started without arguments. This URL is hard-wired into the executable but can be overrun by the environment variable <tt>WWW_HOME</tt>. The system administrator can place a line saying <tt>WWW_HOME="http://localhost"</tt> in <tt>/etc/profile</tt>. The variable must then be exported, either by a separate statement (<tt>export WWW_HOME</tt>) or by appending <tt>WWW_HOME</tt> to the existing export statement: --> Arenaも引数なしで起動するとデフォルトURLを表示します。このデフォルトURLは 実行ファイルに組み込まれていますが、環境変数<tt>WWW_HOME</tt>によって変更 (overrun)することもできます。システム管理者は<tt>/etc/profile</tt>ファイルに <tt>WWW_HOME="http://localhost"</tt>となるように書き込んで下さい(bashなどの 場合はexportするようにします)。例えば、 <code> WWW_HOME="http://localhost" export WWW_HOME </code> とします。 <!-- After relaunching a login shell, the new default URL is now system-wide known to Arena.--> 一度ログインし直せば、新しいデフォルトURLがArenaで有効になります。 <sect2>Netscapeのインストールと設定 <!-- Installing and Configuring Netscape --> <p> <!-- Netscape is a commercial product and thus not included with the Linux distributions. It is either downloadable from the Internet or available from software collections on CDROM. Netscape comes in form of precompiled binaries for every important hardware platform. For installation purposes, it is useful to create a directory <tt>/usr/local/Netscape/</tt> where the archive is unpacked. The files can be kept in place (except for the Java library: follow the instructions in the <tt>README</tt> file that comes with the Netscape binary), and it is sufficient to create a soft link in <tt>/usr/local/bin/</tt> by issuing the command --> Netscapeは商用の製品でLinuxディストリビューションでは配布されていません。 (<bf/訳注:/Caldera Open Linuxなど商用のディストリビューションではライセンス されたNetscapeがついてくるものもあります)。 インターネットやCDROMのソフトウェアコレクションから入手できます。Netscape は各プラットフォーム用にコンパイルされたバイナリ形式で配布されています。 インストールするにはアーカイブファイルを展開するディレクトリとして <tt>/usr/local/Netscape/</tt>を作ります(<bf/訳注:/アーカイブに附属の インストールプログラムを使えば自動的に<tt>/usr/local/netscape/</tt> ディレクトリを作ります)。 Javaライブラリを除くファイルは全てこのディレクトリ内にあります(Netscape ライブラリについては<tt>README</tt>ファイルを参照して下さい)。以下のように してリンクをはります(<tt>/usr/local/bin/</tt>ディレクトリで作業をします)。 <verb> # ln -s /usr/local/Netscape/netscape . </verb> <!-- Netscape is now ready for use and can be configured via the ``Options'' menu. In ``General Preferences'' there is a card ``Appearance'' with the entry ``Home Page Location''. Enter <tt>http://localhost</tt> here and do not forget to save the options (via ``Options'' - - - ``Save Options'') before exiting Netscape. At the next startup, Netscape will now show the Apache `homepage'. --> Netscapeは「Options」メニューで設定できます。「General Preferences」では 「Appearance」カードがあるので、「Home Page Location」に <tt>http://localhost</tt>を指定します。Netscapeを終了するまえに、オプション の保存を忘れないで下さい(「Options」---「Save Options」で)。次回の起動で Apacheのページが開きます(<em/訳注:/これはローカルマシンのページで、Apache インストール時に作られます)。 <sect1>Apacheとブラウザの協力関係 <!-- cooperation of apache and browsers --> <p> <!-- you can now conduct the first real test of both the browser and the http server: simply start any of the available browsers and the <tt/apache: red hat linux web server/ page will pop up. this page shows the file locations and other basics of http server installation. if this page is not displayed please check whether the files mentioned above are in place and whether the browser configuration is correct. close edited configuration files before you start the browser again. if all files are in place and the browsers seem to be configured correctly then examine the network setup of your machine. either the host name is different from what was entered in the configuration, or the network setup as such is not correct. it is utterly important that <tt>/etc/hosts</tt> contains at least a line like --> ブラウザとhttpサーバの最初のテストをします。適当なブラウザを起動すると <tt/apache: red hat linux web server/のページが表示されます。このページでは ファイルの場所とhttpサーバのインストールの基本を説明します。 もしこのページが表示されない場合はファイルが適当な場所にあるか、ブラウザの 設定が正しいかチェックしてください。ブラウザをもう一度開く前に設定ファイル の編集を終らせて下さい。以上の設定が正しければ次にマシンのネットワーク設定 をテストします。ホスト名が設定ファイルに書いたものと違ったりネットワーク セットアップが正しいかどうか。少なくとも<tt>/etc/hosts</tt>に以下の行が あることをチェックします。これは重要です。 <code> 127.0.0.1 localhost localhost.localdomain </code> <!-- which implies that you can connect locally to your machine. one can verify this by issuing any network-sensitive command requiring a host name as argument, like <tt>telnet localhost</tt> (provided <tt>telnet</tt> is installed). if that does not work then the network setup must be verified before continuing with the main task. --> これはマシンにローカル接続をするとき非常に重要です。引数にホスト名を使うような ネットワーク用コマンドを使ってテストします。例えば、<tt>telnet localhost</tt> とします(telnet はすでにマシンにインストールされています)。もしこれがおかし ければ次の作業に移るまえにもう一度ネットワーク設定をチェックしておいて下さい。 <sect1>データベースエンジンとインストール <!-- the database engine and its installation --> <p> <!-- installing the database requires only little more preparation than the previous installation steps. there are a few sql database engines available with different runtime and administrative requirements, and possibly one of the most straightforward systems is msql, or ``mini-sql'' by david hughes. msql is shareware. depending on the version used, commercial sites are charged usd 250.00 and more, private users are charged usd 65.00 and more, and only educational institutions and registered non-profit organizations can use this software free of charge. please note that the exact figures are provided in the licence notes of the database documentation. the figures given here serve as a rough indicator only. --> データベースをインストールするには、netscapeといった上記のインストールよりも、 若干準備しておくことがあります。 ランタイムやアドミニストレーションがそれぞれ違うsqlデータベースエンジンが 2〜3あり、その中で一番わかりやすいシステムであるmsql(mini-sql)を使います。 このシステムはdavid hughes氏によるもので、シェアウェアです。 料金は使うバージョンに依ります。 商用的な使用の場合は250.00ドル(us)以上。個人ユーザの場合は65.00ドル(us)以上。 教育、非商用的な機関の場合はフリーで使うことができます。 正確な価格(figures)はデータベースに附属しているドキュメントのライセンスを 参照してください。ここに書いた価格はだいたいの目安として下さい。 <p> <!-- a few words are in place here why the author chose msql. first of all, there is personal experience. while searching for a database engine the author found msql to be about the easiest to install and maintain, and it provides enough coverage of the sql language to meet general needs. only when writing these lines, the author discovered the following words of praise in alligator descartes' dbi faq (perl database interface faq): --> なぜ著者がmsqlを選択したかその理由を2、3述べます。まず第一に インストール/管理が簡単で、sql言語のカバーしている範囲が十分であることが 挙げられます。ここまで書いた時点で <tt/alligator descartes' dbi faq (perl database interface faq)/ に適当な説明が見つかりました。 <quote> From the current author's point of view, if the dataset is relatively small, being tables of less than 1 million rows, and less than 1000 tables in a given database, then mSQL is a perfectly acceptable solution to your problem. This database is extremely cheap, is wonderfully robust and has excellent support. [...] <p> [日本語訳: 現在の作者の指摘によると、データセットが100,000列以下の表や1000以下の テーブルといった、比較的小さいものならmSQLは完全にあなたの問題を解決して くれます。このデータベースは安くしっかりしたもので優れたサポートがあります。 ] </quote> <!-- Msql is available in two versions now, msql-1.0.16 and msql-2.0.1, which differ in performance (not noticeable in small scale projects) and accompanying software (the newer version comes with more tools, its own scripting language, etc.). We will describe both versions of msql since their installion differs in a few points. --> Msqlは2つのバージョン(<tt/msql-1.0.16, msql-2.0.1/)が入手できます。 この違いはパフォーマンスの違い(小さい仕事では特に差はありません)や添付されて いるソフトウェアの違い(新しいバージョンには多くのツール、スクリプトファイル があります)によっています。以下この2つのバージョンでのインストールについて それぞれ解説していきます(2〜3違いがあります)。 <sect2>msql-1.0.16のインストール <!-- Installing msql-1.0.16 --> <p> <!-- msql is available as source and as compiled executable with ELF support. Using the ELF binaries makes installation easy since the archive file <tt>msql-1.0.16.ELF.tgz</tt> contains a complete absolute directory tree so that all directories are generated properly when unpacked from <tt>/</tt>. --> msqlはソースやELFサポートバイナリとして入手できます。ELFバイナリを使えば インストールは簡単です。アーカイブファイル<tt>msql-1.0.16.ELF.tgz</tt>は そのパッケージ中にインストール先のディレクトリを含んだ形でパッケージ化され ています。そのため展開する時にルートディレクトリで 展開するだけで適当なディレクトリにインストールされます。 <p> <!-- If you decide to compile msql-1.0.16 yourself and are going to use the MsqlPerl package rather than the DBI interface (see a detailed discussion on the difference between these two further down) then be prepared that MsqlPerl might complain during the test suites that some instruction inside msql failed. In this case a patch may be necessary which is described in the MsqlPerl documentation (file <tt/patch.lost.tables/). Notably, this demands including three lines in <tt/msqldb.c/ after line 1400 which says <tt/ entry->def = NULL;/: --> もしmsql-1.0.16をコンパイルして、DBIインターフェースよりもMsqlPerlパッケージ (この両者の違いについては後で述べます)を使う場合に、 MsqlPerlをテスト中「some instruction inside msql failed(msql内で命令が失敗 しました)」となることがあります。この場合MsqlPerlドキュメント (<tt/patch.lost.tables/)に書かれているパッチが必要です。特に<tt/msqldb.c/ の1400行(<tt/ entry->def = NULL;/)からの3行 <verb> *(entry->DB) = 0; *(entry->table) = 0; entry->age = 0; </verb> が大切です。 <!-- The code fragment should now look like --> コードフラグは以下です。 <code> freeTableDef(entry->def); safeFree(entry->rowBuf); safeFree(entry->keyBuf); entry->def = NULL; *(entry->DB) = 0; *(entry->table) = 0; entry->age = 0; </code> <!-- Compiling msql involves several steps. After unpacking the source archive, it is necessary to build a target directory. This is done by saying --> msqlをコンパイルするためにいくつか手順を踏みます。ますソースアーカイブを 展開してターゲットディレクトリを作ります。 <verb> # make target </verb> <!-- If successful, the system will then answer with --> これがうまくいったら、システムは <tscreen><verb> Build of target directory for Linux-2.0.30-i486 complete </verb></tscreen> と表示します。 <!-- You must now change into this newly created directory and run a --> この新しいディレクトリに移動して <verb> # ./setup </verb> と実行します。 <!-- command first. The <tt>./</tt> sequence is necessary to make sure that really the command <tt/setup/ in this directory and not another command which happens to have the same name is executed. You will then be asked questions on the location of the source directory and whether a root installation is desired. These questions answered, the system should then run a number of tests checking for available software (compilers, utilities etc.) and finally say --> <tt>./</tt>シーケンスはこのディレクトリの<tt/setup/コマンドを実行する ために必要です。これを付けないと別の<tt/setup/が実行されてしまいます。 ソースディレクトリやrootインストールが必要かどうか聞かれます。この後 システムはコンパイラ、ユーティリティなどのソフトが使えるかテストします。 <tscreen><verb> Ready to build mSQL. You may wish to check "common/site.h" although the defaults should be fine. When you're ready, type "make all" to build the software </verb></tscreen> と表示されます。そして <verb> # make all </verb> と実行して下さい。 <!-- If everything went as intended, we'll read: --> <tscreen><verb> make[2]: Leaving directory `/usr/local/Minerva/src/msql' <-- [msql] done Make of mSQL complete. You should now mSQL using make install NOTE : mSQL cannot be used free of charge at commercial sites. Please read the doc/License file to see what you have to do. make[1]: Leaving directory `/usr/local/Minerva/src' </verb></tscreen> <!-- All binaries must then be made visible to the search paths by creating soft links in <tt>/usr/local/bin/</tt>. Change to that directory and issue the command --> バイナリは<tt>/usr/local/bin/</tt>にソフトリンクを作ることで検索パス に通るようにします。<tt>/usr/local/bin/</tt>ディレクトリに移動して <verb> # ln -s /usr/local/Minerva/bin/* . </verb> と実行して下さい。<!-- after which the links will be properly set. --> <sect2>msql-1のテスト <!-- Testing msql-1 --> <p> <!-- After the installation it is now possible to test whether the database works. Before anything else is done, the server daemon must be started. The system administrator holding root privileges issues the command --> インストール後、データベースがちゃんと動作するかどうかテストします。 サーバデーモンをスタートさせるためにシステム管理者(root権限)としてコマンドを 実行します。 <verb> # msqld &ero; </verb> <!-- (do not forget to add the <tt>&</tt>, otherwise msql won't run in the background.) after which the following screen message appears: --> (バックグランドでmsqlを実行するために、<tt>&</tt>を付けるのを忘れない ようにして下さい)。以下のメッセージが表示されます。 <tscreen><verb> mSQL Server 1.0.16 starting ... Warning : Couldn't open ACL file: No such file or directory Without an ACL file global access is Read/Write </verb></tscreen> <!-- This message tells us that everything so far worked since we did not set up any access restrictions. For the moment it is sufficient to start the msql daemon from within a shell but later we may want to have the system startup automatically execute this command for us. The command must then be mentioned in a suitable <tt>rc.d</tt> script. Only now the administrator can issue the first genuine database command: --> このメッセージは、アクセス制限を設定していないために動作していない ということを意味しています。さしあたってシェル内からmsqlデーモンを開始 できます。そこでコマンドを適当な<tt>rc.d</tt>スクリプトに書いておきます( 管理者だけがデータベースコマンドを実行できます)。 <verb> # msqladmin create inventur </verb> (<em/訳注:/このコマンドの実行で空のデータベースinventurが作られます)。 <!-- msql replies by saying <tt>Database "inventur" created.</tt>. As a further proof, we find that the directory <tt>/usr/local/Minerva/msqldb/</tt> contains now the empty subdirectory <tt>../inventur/</tt>. We could manipulate the newly created database with the administration tools; these procedures are all covered in detail in the msql documentation. --> msqlは<tt>Database "inventur" created.</tt>と返答します。 <tt>/usr/local/Minerva/msqldb/</tt>ディレクトリに空の<tt>../inventur/</tt> サブディレクトリができます。この新しいデータベースはアドミニストレーション ツール(詳細はmsqlドキュメントに書かれています)を使って操作できます。 <sect2>msql-2.0.1のインストール <!-- Installing msql-2.0.1 --> <p> <!-- There is now a newer, more powerful version of Hughes' mSQL server available the installation of which is different in a few points. Installing msql-2 from scratch involves the following steps. Copy the archive to your extraction point, e.~g.~ <tt>/usr/local/msql-2/</tt>, then untar the archive: --> 新しくパワフルなHugheのmSQLサーバがあり、以前のバージョンと2〜3の点で インストールに違いがあります。msql-2のインストールをはじめから行うには 以下のステップをふみます。適当なディレクトリ(例えば<tt>/usr/local/msql-2/</tt>) にアーカイブをコピーして展開します。 <verb> # tar xfvz msql-2.0.1.tar.gz </verb> (<em/訳注:/アーカイブは以下のサイトから入手できます。 <url url="http://www.hughes.com.au/software/msql2/">) <!-- Change to the root direction of the install tree and issue a --> <verb> # make target </verb> と実行します。<!-- Change to <tt>targets</tt> and look for your machine type. There should be a new subdirectory <tt>Linux-</tt><it>(your version)-(your cpu)/</it>. Change to that directory and start the setup facility located here: --> <tt>targets</tt>に変更してマシンタイプを選びます。新しいサブディレクトリ <tt>Linux-</tt><it>(バージョン)-(CPU)/</it> このディレクトリに変更して以下のようにセットアップをスタートします。 <verb> # ./setup </verb> <!-- There is also a file <tt>site.mm</tt> which can be edited. Maybe you have got used to the directory name <tt>/usr/local/Minerva/</tt> and want to preserve it? In this case change the <tt>INST_DIR=...</tt> line to your desired target directory. Otherwise, leave everything as it is. --> 編集可能な<tt>site.mm</tt>ファイルがあります。ディレクトリ名 <tt>/usr/local/Minerva/</tt>を使っていることと思います。 保存したいですか?この場合<tt>INST_DIR=...</tt>の行に保存したいディレクトリ 名を書き込んで下さい。 <!-- Now you can start building the database:--> データベースを構築します。 <verb> # make # make install </verb> <!-- If everything went successfully, we'll see a message like: --> インストールに成功すると以下のメッセージが表示されます。 <tscreen><verb> [...] Installation of mSQL-2 complete. ********* ** This is the commercial, production release of mSQL-2.0 ** Please see the README file in the top directory of the ** distribution for license information. ********* </verb></tscreen> <!-- After all is installed properly we have to take care of the administration details. Here, the real differences from msql-1 begin. First, a user <tt/msql/ is created which is responsible for database administration. --> インストールが適切に行われたら次はデータベース管理の詳細に注意を 払わなければなりません。ここでmsql-1とは違う作業が必要です。データベース 管理を担うユーザ<tt/msql/を作ります: <verb> # adduser msql </verb> <!-- Then we have to change all ownerships in the mSQL directory to <tt>msql</tt> by saying: --> mSQLディレクトリのオーナーを<tt>msql</tt>に変更します。 <verb> # cd /usr/local/Minerva # chown -R msql:msql * </verb> <!-- Then we create soft links for all database binaries in <tt>/usr/local/bin/</tt> by saying: --> 次に<tt>/usr/local/bin/</tt>のデータベースバイナリへのソフトリンクを 作ります。 <verb> # ln -s /usr/local/Minerva/bin/* . </verb> 以上です。 <sect2>msql-2のテスト <!-- Testing msql-2 --> <p> <!-- We can now start the database server by issuing the command <tt>msql2d &</tt> and should get a response similar to this one: --> データベースサーバは<tt>msql2d &</tt>コマンドによって開始され、 <tscreen><verb> Mini SQL Version 2.0.1 Copyright (c) 1993-4 David J. Hughes Copyright (c) 1995-7 Hughes Technologies Pty. Ltd. All rights reserved. Loading configuration from '/usr/local/Minerva/msql.conf'. Server process reconfigured to accept 214 connections. Server running as user 'msql'. Server mode is Read/Write. Warning : No ACL file. Using global read/write access. </verb></tscreen> と応答が出ます。<!-- That looks perfect. The database is compiled and in place, and we can now continue with the perl modules since these rely partially on the presence of a working database server for testing. --> これで完璧です。データベースはコンパイルされ適当な場所にあります。 続いてperlモジュールを継続します。perlモジュールはテスト用に動作している データベースサーバの振舞いに部分的に基づいています。 <p> <!-- Accidentally, this is also a good moment to print the complete manual that comes with msql-2.0.1: --> きっかけがあればmsql-2.0.1に附属しているマニュアルの印刷をしておくと よいでしょう: <verb> # gzip -d manual.ps.gz # lpr manual.ps </verb> <!-- We can proceed to building the interfaces now, but it is a good idea to keep the newly created SQL server up and running since that makes testing the interface libraries somewhat simpler. --> 続いてインターフェースの構築を行いますが、新しく作ったSQLサーバを保存して 実行したほうがよいでしょう。そのほうが安心してインターフェースライブラリ のテストができます。 <sect1>インターフェースの選択:DBI/mSQL, MsqlPerl, Lite <!-- Choice of Interfaces: DBI/mSQL, MsqlPerl, and Lite --> <p> <!-- A frequently quoted saying in the Camel Book (the authorative perl documentation) states that there is more than one way to achieve a result when using perl. This, alas, holds true for our model application, too. Basically there are three ways to access an msql database via CGI. First of all the question is whether or not perl shall be used. If we use perl (on which this article focuses) then we still have the choice between two completely different interface models. Besides using perl, we can also employ msql's own scripting language, called Lite, which is reasonably simple and a close clone of C. --> perlを使う時に参考になることがらがCamel Book(<em/訳注:/「ラクダ本」と 呼ばれるものです)に書かれています。これは今回のモデルアプリケーションを も書かれています。基本的にCGIを経由してmsqlデータベースにアクセスする方法が 以下3つあります。 はじめにperlを使うかどうかということに関することです。 (この文書が対象としている)perlを使うなら二つの異なるインターフェースモデル のどちらかを選べます。perlを使う場合はmsql独自のスクリプト言語(Lite)も使う ことができます。非常にわかりやすく、C言語に近いクローンです。 <sect2>DBI と DBD-mSQL <!-- DBI and DBD-mSQL --> <p> <!-- By the time of this writing, using perl's generic database interface called DBI is the method of choice. DBI has a few advantages: It provides unified access control to a number of commercial databases with a single command set. The actual database in use on a given system is then contacted through a driver which effectively hides the pecularities of that database from the programmer. Being such, using DBI provides for a smooth transition between different databases by different makers. In one single script it is even possible to contact several different databases. Please refer to the DBI-FAQ for details. There is, however, one drawback: The DBI interface is still under development and shows rapidly galloping version numbers (sometimes with updates taking place within less than a month). Similarly, the individual database drivers are also frequently updated and may rely on specific versions of the database interface. Users making first-time installations should stick to the version numbers given in this article since other versions may cause compilation and testing problems the trouble shooting of which is nothing for the faint-hearted. --> この執筆の時点までにDBIと呼ばれるperlのデータベースインターフェースが 。 DBIは2,3の役立つ点があります:コマンド一つで多くの商用データベースを操作 できる統一されたアクセスコントロールが提供されています。与えられたシステム で実際のデータベースはプログラマからデータベースの横取り(pecularities)を 防ぐドライバを使ってアクセスできる。DBIを使うことでマーカーによる異なるデータ ベース間でスムーズな移行ができる。一つのスクリプトで複数のデータベースに アクセスできる。詳しくはDBI-FAQを参照して下さい。しかし一つ欠点もあります: DBIインターフェースはまた開発中でバージョンがどんどん変わっています(一カ月 も経たないうちに新しいものに変わってしまうこともあります)。同様にそれぞれの データベースドライバもアップデートされ特定のインターフェースバージョンに 依存していることもあります。初期にインストールしたユーザーはこの文書で挙げた バージョンをつ使わないといけないかもしれません。というのも他のバージョンでは 複雑になってしまったり、テストのトラブルシューティングも意味のないものに なってしまうことがあるからです。 <sect2>MsqlPerl <p> <!-- MsqlPerl is a library for directly accessing msql from perl scripts. It bypasses the DBI interface and is fairly compact. Though it works fine with both versions of msql, its usage is not promoted anymore in favour of the generalized DBI interface. Nonetheless, in a given installation it may prove to be the interface of choice since it is small and easy to install. Notably, it has less version dependencies than revealed by the interaction of DBI and particular database drivers. --> MsqlPerl はperlスクリプトからmsqlに直接アクセスするためのライブラリです。 DBIインターフェースを回避してとてもコンパクトです。 msqlの両バージョンともよく動作しますが、その使い方は一般化されたDBI インターフェースを使う(promoted)ことはできません。 ですが小さいシステムでインストールが容易なので選択するインターフェースと します。特にDBIや特定のデータベースドライバよりもバージョンに依存しません。 <sect2> msqlのスクリプト言語:Lite <!-- msql's own scripting language: Lite --> <p> <!-- Last but not least msql-2 comes with its own scripting language: Lite. The language is a close relative of C stripped of its oddities with additional shell-like features (in a way, something like a very specialized version of perl). Lite is a simple language and is well documented in the msql-2 manual. The msql-2 package also comes with a sample application sporting Lite. --> msql-2ではスクリプト言語(Lite)を持っています。この言語はシェルライクな 特徴を追加したちょっと変わったものです(特定のPerlバージョンに似ています)。 Liteはシンプルな言語でmsql-2マニュアルに詳しく書かれています。msql-2 パッケージにはLiteを使った簡単なアプリケーションも附属しています。 <p> <!-- We will not describe Lite here because it is well documented but fairly specific to msql-2, and because it is assumed that the readers of this article have a basic interest in and a basic understanding of perl. Nonetheless it is highly recommended to have a closer look at Lite: it may well be the case that Lite offers the solution of choice in an exclusive msql-2 environment (implying no other databases are involved) due to its simplicity and straightforward concept. --> Liteについては優れた文書(msql-2に特定した内容)があるのでここではLiteに ついては説明しません。またこの文書を読んでいる読者はperlについて基礎的な 理解があるものと想定しています。 ですがLiteをよく調べてみることをお奨めします。Liteはそのシンプルで 直観的な概念に関してmsql-2環境(他のデータベースで行われているような) での解決を提供している場合があります。 <sect1>一般的な方法:DBI と DBD-msql <!-- Going the generic way: DBI and DBD-msql --> <p> <!-- We assume that perl was installed during the system setup or via the package manager mentioned above. No further details will be given here. Nonetheless we first test whether our version of perl is up to date: --> すでにシステム設定でperlをインストールしてあるか上記したパッケージマネージャを 使ってperlが入っているものとします。perlについては詳しく述べません。 perlのバージョンを見るには、 <verb> # perl -v </verb> とします。 <!-- perl should respond with the following message: --> perlは以下のメッセージを表示します。 <tscreen><verb> This is perl, version 5.003 with EMBED Locally applied patches: SUIDBUF - Buffer overflow fixes for suidperl security built under linux at Apr 22 1997 10:04:46 + two suidperl security patches Copyright 1987-1996, Larry Wall [...] </verb></tscreen> <!-- So far, everything is fine. The next step includes installing the perl libraries for databases in general (DBI), the msql driver (DBD-mSQL) and CGI. The CGI driver is necessary in any case. The following archives are necessary: --> これで問題なければ、次はデータベース用のperlライブラリ(DBI)、msqlドライバ (DBD-mSQL)、CGIをインストールします。CGIドライバはいろんな場面で必要に なります。3つのアーカイブが必要です: <enum> <item> DBI-0.81.tar.gz <item> DBD-mSQL-0.65.tar.gz <item> CGI.pm-2.31.tar.gz (あるいはこれ以上のもの) </enum> <!-- A caveat is necessary here for beginners: the test installation described here works fine using software with <em/exactly/ these version numbers, and combinations of other versions failed in one or the other way. Debugging flawed version combinations is nothing for those who are not very familiar with the intimate details of the calling conventions etc. of the interfaces. Sometimes only a method is renamed while performing the same task, but sometimes the internal structure changes significantly. So, again, stick with these version numbers if you want to be on the safe side even if you discover that version numbers have increased in the meantime. Frequent updates of these interfaces are the rule rather than the exception, so you should really anticipate problems when installing other versions than those indicated here.--> 初心者の方に注意があります。ここまでで述べてきたテストインストール は上記したバージョンを使って正確に動いています。他のバージョンでは エラーとなるかもしれません。欠陥のあるバージョンのデバッグは 呼び出しの規則(conventions)やインターフェースについて詳しく ない人にはどうしようもありません。 同じ動作をしているものをリネームするのが一つの方法ですが 内部構造が著しく変更されていることがあったりします。 そこで それまでは新しいバージョンに上がっていても、安全に使いたいのであれ ばここで紹介したバージョンにするよう心がけて下さい。 <p> <!-- It is very important that the database driver for mSQL (DBD-mSQL) is installed <em/after/ the generic interface DBI.--> mSQL((DBD-mSQL)用のデータベースドライバはインターフェース(generic interface) DBIの<em/後に/インストールするということは重要です。 <p> <!-- We start by creating the directory <tt>/usr/local/PerlModules/</tt> as it is very important to keep the original perl directory tree untouched. We could also choose a different directory name since the name is completely uncritical, and unfortunately that is not really mentioned in the README files of the verious perl modules. Having copied the above-mentioned archives to <tt>/usr/local/PerlModules/</tt> we unpack them saying --> オリジナルのperlディレクトリを保存するために<tt>/usr/local/PerlModules/</tt> ディレクトリを作ることから始めます。ディレクトリ名は特に決っていないので これとは違う名前にすることもできます(どのperlモジュールのREADMEファイルにも ディレクトリ名については書かれていません)。上記のアーカイブを <tt>/usr/local/PerlModules/</tt>にコピーして、 <verb> # tar xzvf [archive-file] </verb> 3つのアーカイブをそれぞれ展開します([archive-file]はアーカイブ名に 置き換えて下さい)。 <p> <!-- for every single of the three archives. Do not forget to supply the real archive name to <tt>tar</tt>. The installation process for the three modules is essentially stardardized; only the screen messages showing important steps of individual packages are reproduced here. --> 3つのモジュールのインストールプロセスは通常通り行います(このドキュメント では各パッケージで重要なものだけを書き出してします)。 <sect2>perlデータベースインターフェース DBI のインストール <!-- Installing perl's Database Interface DBI --> <p> <!-- The database interface must always be installed before installing the specific database driver. Unpacking the DBI archive creates the directory <tt>/usr/local/PerlModules/DBI-0.81/</tt>. Change to that directory. There are a <tt>README</tt> file (you should read it) and a perl-specific makefile. Now issue the command --> データベースインターフェースは特定のデータベースドライバをインストール する前に入れておいて下さい。DBIアーカイブを展開すると <tt>/usr/local/PerlModules/DBI-0.81/</tt>ディレクトリが作られるので このディレクトリに移動します。<tt>README</tt>ファイルとperl用makefileが あります。 <verb> # perl Makefile.PL </verb> と実行して下さい。<!-- The system should answer with a lengthy message of which the most important part is shown here:: --> 次々とメッセージが表示されます。そのうち重要な箇所を引用します。 <tscreen><verb> [...] MakeMaker (v5.34) Checking if your kit is complete... Looks good NAME => q[DBI] PREREQ_PM => { } VERSION_FROM => q[DBI.pm] clean => { FILES=>q[$(DISTVNAME)/] } dist => { DIST_DEFAULT=>q[clean distcheck disttest [...] Using PERL=/usr/bin/perl WARNING! By default new modules are installed into your 'site_lib' directories. Since site_lib directories come after the normal library directories you MUST delete old DBI files and directories from your 'privlib' and 'archlib' directories and their auto subdirectories. Writing Makefile for DBI </verb></tscreen> <!-- This looks good, as the program says, and we can proceed with the next step: --> ちゃんと実行されているようです。次に <verb> # make </verb> と実行します。<!-- If no error message occurs (the detailed protocol dumped on screen is <em/not/ an error message) we test the newly installed library with the command --> もしエラーメッセージが出なければ(画面に表示されるプロトコルはエラーメッセージ ではありません)、新しくインストールされるライブラリをテストします。 <verb> # make test </verb> <!-- Watch the output for the following lines (you can always scroll back with <tt/[Shift]-[PgUp]/): --> 表示される出力は<tt/[Shift]-[PgUp]/でスクロールできます。 <tscreen><verb> [...] t/basics............ok t/dbidrv............ok t/examp.............ok All tests successful. [...] DBI test application $Revision: 1.2 $ Switch: DBI-0.81 Switch by Tim Bunce, 0.81 Available Drivers: ExampleP, NullP, Sponge ExampleP: testing 2 sets of 5 connections: Connecting... 1 2 3 4 5 Disconnecting... Connecting... 1 2 3 4 5 Disconnecting... Made 10 connections in 0 secs ( 0.00 usr 0.00 sys = 0.00 cpu) test.pl done </verb></tscreen><!-- The final step is to install all files in their proper directories. The following command will take care of it: --> 最後にインストールするディレクトリにファイルを入れます。 <verb> # make install </verb> このコマンドは十分に確認してから実行して下さい。 <!-- No more duties are left. If for some reason the installation failed and you want to redo it do not forget to issue --> これ以上することはありません。もしなんらかの理由でインストールに失敗したら 忘れないうちに作業をやり直して下さい。 <verb> # make realclean </verb> <!-- first. This will remove stale leftovers of the previous installation. You can also remove the files which were installed by copying the screen contents (shown abbreviated) --> ますはじめに。このコマンドは前のインストールで不用なものを削除します。 また画面の表示(以下省略して挙げました)をコピーしてインストールしたファイルも 削除できます。 <tscreen><verb> Installing /usr/lib/perl5/site_perl/i386-linux/./auto/DBI/DBIXS.h Installing /usr/lib/perl5/site_perl/i386-linux/./auto/DBI/DBI.so Installing /usr/lib/perl5/site_perl/i386-linux/./auto/DBI/DBI.bs [...] Writing /usr/lib/perl5/site_perl/i386-linux/auto/DBI/.packlist Appending installation info to /usr/lib/perl5/i386-linux/5.003/perllocal.pod </verb></tscreen> <!-- into a file, replacing every <tt/Installing/ with <tt/rm/. Provided you named the file <tt/uninstall/ you can then say --> この<tt/Installing/を<tt/rm/に置き換えます。これを<tt/uninstall/に保存して <verb> # . uninstall </verb> <!-- which will remove the recently installed files. --> と実行すれば、インストールされたファイルが削除されます。 <sect2>perl の msql ドライバ DBD-mSQL <!-- perl's msql Driver DBD-mSQL --> <p><!-- The msql driver can only be installed <em/after/ a successful installation of perl's generic database interface. --> msqlドライバはperlデータベース(generic database)インターフェースの インストールが<em/うまくいった後に/インストールします。 <!-- The basic steps are the same as above; so first go through -->インストール過程は上記したステップと同じです。 <verb> # perl Makefile.PL </verb> <!-- Here, the system should answer with an urgent warning to read the accompanying documentation. It will then detect where msql resides, and asks which version you use: --> ここでシステムは添付ドキュメントを読むように警告を表示します。ここで msqlの場所を見つけます。 <tscreen><verb> $MSQL_HOME not defined. Searching for mSQL... Using mSQL in /usr/local/Hughes -> Which version of mSQL are you using [1/2]? </verb></tscreen> <!-- State your correct version number. Quite a few lines of text will follow. Watch for the following ones: --> 正しいバージョンを入力して下さい。以下2,3行を表示します。 <tscreen><verb> Splendid! Your mSQL daemon is running. We can auto-detect your configuration! I've auto-detected your configuration to be running on port: 1114 </verb></tscreen> <!-- You can now test the driver by saying --> 以下のようにしてドライバのテストをします。 <verb> # make test </verb> <!-- Again, a lengthy output follows. If it ends with --> 再び長い出力があり、 <tscreen><verb> Testing: $cursor->func( '_ListSelectedFields' ). This will fail. ok: not a SELECT in msqlListSelectedFields! Re-testing: $dbh->do( 'DROP TABLE testaa' ) ok *** Testing of DBD::mSQL complete! You appear to be normal! *** </verb></tscreen> で終ります。 <!-- you are on the safe side of life and can install your driver by saying -->これで大丈夫です。 <verb> # make install </verb> としてインストールします。 <!-- You are now ready to go and can skip the next paragraph. --> もう準備できたので次の節は飛ばしてください。 <sect1>MsqlPerlインターフェース <!-- The MsqlPerl Interface --> <p> <!-- If you decide to use the exclusive MsqlPerl interface then no generic database driver is needed, only <tt/MsqlPerl-1.15.tar.gz/, since, as mentioned earlier, MsqlPerl provides a direct interface between perl and the database server without using the DBI interface. Installing and testing is straightforward. --> もしMsqlPerlの方を選んだなら、<tt/MsqlPerl-1.15.tar.gz/以外に特定のデータ ベースドライバ(generic database driver)は必要ありません。始めに書いたように MsqlPerlはperlとデータベースサーバ間でDBIインターフェースを使わずに直接 やり取りをするからです。直接インストール、テストします。 <p> <!-- After saying <tt>perl Makefile.PL</tt> the make utility can be started. First you have to answer the question where mSQL resides. If it resides in <tt>/usr/local/Minerva/</tt> the default answer can be confirmed. --> <tt>perl Makefile.PL</tt>と実行するとユーティリティがスタートします。 はじめにどこにmSQLがあるか答えます。<tt>/usr/local/Minerva/</tt>なら デフォルトのままでよいです。 <p> <!-- Then do a <tt>make test</tt>. Before doing so you must ensure that you have a database named <tt>test</tt> and that you have read and write permissions for it. This can be done by --> そして<tt>make test</tt>とします。この前に<tt>test</tt>というデータベース があることを確認してパーミッションを読み書き可能にして下さい。 <verb> # msqladmin create test </verb> と実行します。 <sect1>perlのCGIライブラリ <!-- perl's CGI library --> <p> <!-- Installing perl's CGI part is the simpliest of the three steps. Execute the following commands in the given order and everything is done: --> perlのCGIパートは3つのシンプルな段階にわかれています。以下のコマンドを 実行して下さい。 <verb> # perl Makefile.PL # make # make install </verb> <!-- Unlike the previous drivers this interface does not have a test option (<tt># make test</tt>) whereas the other modules <em/should/ be tested in any case. --> 前のドライバと違い、このインターフェースはテストオプション (<tt># make test</tt>)を持っていません。ところが他のモジュールは 任意のケースでテストされる必要があります。 <p> <!-- A subdirectory with CGI example scripts is also created. You can copy the contents of this directory into <tt>/home/http/cgi-bin/</tt> and use the browser to experiment with the scripts. --> CGIのサンプルスクリプトがあるサブディレクトリがこれで作られます。 このディレクトリの中身を<tt>/home/http/cgi-bin/</tt>にコピーして スクリプトのテストのためにブラウザを起動してみて下さい。 <sect1>チェックリストのインストール <!-- Installation Checklist --> <p> <!-- We went through the following steps, in this order: --> 以下の順に作業を進めます。 <enum> <item><!-- Install Linux with networking support--> Linuxをネットワークサポートでインストールする <item><!-- Install a http server, e.~g.~Apache --> httpサーバのインストール(Apacheなど) <item><!-- Install a browser, e.~g.~Arena, lynx or Netscape--> ブラウザのインストール(Arena, lynx, Netscapeなど) <item><!-- Install an SQL server, e.~g.~msql--> SQLサーバのインストール(msql) <item><!-- Install a suitable perl SQL interface--> 適当なperl SQLインターフェースをインストール <item><!-- Install the CGI files--> CGIファイルのインストール </enum> <!-- Finally, you can do some clean-up. All source trees for msql and the perl modules can be safely deleted (however, you should not delete your archive files!) since the binaries and documentation are now based in different directories. --> 最後にクリーンアップを行います。バイナリやドキュメントは異なるディレクトリ にあるのでmsqlのソースツリーやperlモジュールは安全のために削除しておきます (アーカイブファイルは削除しなくてよいです)。 <sect>テストデータベースの実行 <!-- Running an Example Database --> <p> <!-- After completing the system installation we can now finally run a model application. Depending on the version of msql installed and the perl database interface used, we have to modify the sample programs in a few points. --> システムインストール終了後、モデルアプリケーションを実行することができます。 インストールしたmsqlのバージョンやperlデータベースインターフェースに依存し し、サンプルプログラムを2〜3修正しなければいけません。 <p> <!-- First however, the file <tt/index.html/ residing in <tt>/home/httpd/html/</tt> must be modified to allow calling a sample database application. We can place our database (which we call <tt/database.cgi/ or <tt/inventur.cgi/ here despite its archive name <tt/perl.lst.ck/) in <tt>/home/httpd/html/test/</tt>. --> まず<tt>/home/httpd/html/</tt>にある<tt/index.html/ファイルがサンプルデータ ベースアプリケーションを呼び出すように修正します。<tt>/home/httpd/html/test/ </tt>のデータベース(アーカイブ名は<tt/perl.lst.ck/ですが、<tt/database.cgi/ あるいは<tt/inventur.cgi/と呼びます)に置き換えます。 <p> <!-- We add one line (of course, depending on your installation choices) similar to the following to <tt/index.html/: --> <tt/index.html/に一行を追加します(もちろん各自のインストールに合わせて下さい)。 <code> <LI>Test the <A HREF="test/database.cgi">Database, DBI:DBD-mSQL style!&etago;A> <LI>Test the <A HREF="test/inventur.cgi">Database, MsqlPerl style!&etago;A> </code> <!-- Usually you should only pick one of these two choices but if you have both types of database interface installed you can leave both lines here as they are. You can then compare performance, etc. --> 通常はこの2つのうちから一つを選択するのですが、もし両方ともインストール している場合は上のように2行を追加することもできます。2つを使えれば パフォーマンスなどを比較することもできます。 <sect1>MsqlPerlサンプルスクリプトの追加 <!-- Adapting the sample script for MsqlPerl --> <p> <!-- Our sample script has to be told to use the MsqlPerl interface. The modification takes place in several locations. First, near the beginning of the file, we change the <tt/use/ clause: --> サンプルスクリプトはMsqlPerlインターフェースを使うようにします。 そのために適当な箇所を書き換えます。はじめにファイルのはじめあたりの<tt/use/ 指定を変更します。 <code> # # use DBI; # Generisches Datenbank-Interface use Msql; </code> <!-- Then, near line 27, the MsqlPerl syntax does not require the mentioning of a specific driver: --> そして27行付近でMsqlPerl syntaxが特定のドライバを必要としないようにします。 <code> # $dbh = DBI->connect($host, $database, '', $driver) || $dbh = Msql->connect($host, $database) || </code> <!-- Then, from line 33 onward throughout the whole script, we have to change all instances of <tt/do/ against <tt/query/: --> また33行から最後まで<tt/do/を<tt/query/に変更します。 <code> # $dbh->do("SELECT * FROM hw") || db_init($dbh); $dbh->query("SELECT * FROM hw") || db_init($dbh); </code> <!-- Finally, in MsqlPerl speak, line 207 can be commented out: --> 最後に、207行をコメントアウトします。 <code> # $sth->execute || msg("SQL Error:", $sth->errstr); </code> <!-- In addition, it may become necessary to swap all <tt/errstr/ calls like the one in the preceding code fragment against <tt/errmsg/. This is also version dependent. After these modifications, the script should run smoothly. --> また<tt/errmsg/に対する前のコードフラグメントの一つのように全<tt/errstr/コール をスワップする必要があります。これはバージョンに依存するものです。 以上の作業が終了したらスクリプトはスムーズに実行されます。 <sect1>msql-2用サンプルスクリプトの追加 <!-- Adapting the sample script for msql-2 --> <p> <!-- The SQL syntax was redefined during the development of mslq-2. The original script will fail to execute the table initialization statements in lines 45 - - 58. The <tt/primary key/ modifier is no longer supported by msql-2, and should simply be skipped: --> SQL syntaxはmslq-2の開発中に再定義されました。オリジナルスクリプトは 45〜58行にテーブル初期化ステートメントを実行することはできません。 <tt/primary key/ modifierはmsql-2ではもうサポートされていません。 以下をスキップします: <code> $dbh->do(<<EOT) || die $dbh->errstr; # Neue Personen-Tabelle 新規個人テーブル create table person ( # We do not need the 'primary key' modifier anymore in msql-2! # pn int primary key, # Personalnummer個人番号 pn int, # Personalnummer name char(80), # Nachname, Vorname 姓、名 raum int # Raumnummer空間番号 ) EOT $dbh->do(<<EOT) || die $dbh->errstr; # Neue Hardware-Tabelle create table hw ( # We do not need the 'primary key' modifier anymore in msql-2! # asset int primary key, # Inventurnummer 管理番号 asset int, # Inventurnummer name char(80), # Bezeichnung 名称 person int # Besitzer 所有者 ) EOT </code> <!-- Unfortunately, this specific script will then accept new entries with identical personnel numbers; the msql-1 modifier <tt/primary key/ intends to prevent exactly this behaviour. The msql-2 documentation shows how to use the <tt/CREATE INDEX/ clause to create unique entries. --> このスクリプトは個人番号が同じものも新しくエントリーしてしまいます。 msql-1は<tt/primary key/をこの動作を防ぐのに使います。msql-2ドキュメント は<tt/CREATE INDEX/が唯一のエントリ発行を閉じる方法について書かれています。 <sect>まとめと今後の見通し <!-- Conclusion and Outlook --> <p> <!-- If you have installed msql-2 on your system then you can have a look at the sample programs written in Lite, msql-2's own scripting language. --> もしmsql-2をシステムにインストールしているなら、Lite, msql-2のスクリプト 言語で書かれたサンプルプログラム、msql-2独自のスクリプト言語を見つけられます。 <p> <!-- Either version of msql comes with a basic set of administration tools which allow the user to create and drop tables (<tt/msqladmin/) and examine database structures (<tt/relshow/). --> msqlのどちらのバージョンもユーザーを発行しテーブル(<tt/msqladmin/)に落せる ようにした管理ツールの基本セット、データベース構造のテスト(<tt/relshow/) がついています。 <p> <!-- The second generation msql (i.e. msql-2) has a few more genuinely useful utilities: <tt/msqlimport/ and <tt/msqlexport/. These allow the dumping of flat line data files into and out of the SQL database. They can be used for loading quantities of existing data <em/d'un coup/ into existing tables, or extract flat data from tables, and the user does not have to deal with writing a <em/single/ line of perl or SQL or whatever code for this task. --> 2世代目のmsql(msql-2)にはより価値のあるユーティリティ(<tt/msqlimport/ と<tt/msqlexport/)がついています。これらはSQLデータベースにフラットライン データファイル(flat line data file)のダンプをするものです。 すでにあるデータ<em/d'un coup/をすでにあるテーブルに読み込んだり フラットデータをテーブルから展開したりするのに使われます。ユーザーはこの 作業をするためのperlやSQLあるいはどのようなコードでも1行で書くことはでき ません。 <p> <!-- If you want to write your own perl scripts dealing with databases you'll find sufficient support in the example files and the extensive on-line documentation that comes with the DBI module. --> もしデータベースを取り扱うperlスクリプトを書きたい場合は サンプルファイルや、DBIモジュールに附属している広範囲に渡ったオンライン ドキュメントを参照して下さい。 <p> <!-- Anyway, you are now ready to go and present your data to the users of your own network, or even the WWW. --> とにかくこれでネットワークユーザー、WWWのユーザーにデータを表示する準備が できました。 <hrule> [日本語訳:伊佐冶 哲, <htmlurl url="mailto:isaji@mxu.meshnet.orjp" name="isaji@mxu.meshnet.orjp"><p> 日本語訳について感想、訂正などありましたらご連絡下さい] </article>