<!-- -*- mode:text coding:euc-jp -*-
   $FML: fml_on_unix.sgml,v 1.13 2008/08/18 13:21:42 fukachan Exp $
-->


<chapter id="install.fml.unix">
	<title>
	Unix 上での &fml8; のインストール
	</title>


<sect1 id="install.fml.unix.prepare">
	<title>
	インストールの準備
	</title>


<para>
configure を実行する(後述)前に、
ユーザ fml とグループ fml を作ってください。
<screen>
例

% su root
# groupadd fml
# useradd -g fml -m fml
</screen>
</para>

</sect1>


<!-- ====================================================== -->
<sect1 id="install.fml.unix.configure">
	<title>
	configure を実行する
	</title>


<para>
configure (by GNU autoconf) および make を実行して下さい。
configure の前に、
ユーザ fml とグループ fml を作っておく必要がありますので注意して下さい。
ここまでの作業をまとめて書くと、次のようになります。
<screen>
% su root
# groupadd fml
# useradd -g fml -m fml
# ./configure
# make install
</screen>
configure が適宜 script 群や .cf 群の変数を書き換えます。
</para>

<para>
make install を実行する際には、
(configure が生成した) etc/fml/install.cf を元に、
(configure が生成した) install.pl (perl script) が、
実際のインストール作業を行ないます。
</para>

<para>
ユーザ名や基本的なディレクトリ構成などは configure の引数で変更して下さい。
変更できる変数は以下のものです。configure --help で表示されます。
fml では各ディレクトリに、さらに /fml といった suffix をつけます。
変更できるのは、その直前の prefix 部分までです。
<screen>
変数            configure のデフォルト値    fml の利用するディレクトリ例
--------------------------------------------------------
prefix          /usr/local                  /usr/local
exec_prefix     /usr/local                  /usr/local
bindir          ${exec_prefix}/bin          /usr/local/bin
sbindir         ${exec_prefix}/sbin         /usr/local/sbin
libexecdir      ${exec_prefix}/libexec      /usr/local/libexec/fml
datadir         ${prefix}/share             /usr/local/share/fml
sysconfdir      ${prefix}/etc               /usr/local/etc/fml
sharedstatedir  ${prefix}/com
localstatedir   ${prefix}/var
libdir          ${exec_prefix}/lib          /usr/local/lib/fml
includedir      ${prefix}/include
oldincludedir   /usr/include
infodir         ${prefix}/info
mandir          ${prefix}/man
</screen>
そして、これらの変数も configure の引数で上書きすることができます。
<screen>
fmlconfdir      $sysconfidr/fml             /usr/local/etc/fml        
mlspooldir      /var/spool/ml               /var/spool/ml
fml_owner       fml                         fml
fml_group       fml                         fml
default_domain  推測する                    推測する
</screen>
これらのオプションは
<screen>
configure --help 
</screen>
で表示されます。
<screen>
例

./configure --help

`configure' configures this package to adapt to many kinds of systems.

	... snip ...

Installation directories:
  --prefix=PREFIX         install architecture-independent files in PREFIX
                          [/usr/local]
  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
                          [PREFIX]

	... snip ...

Fine tuning of the installation directories:
  --bindir=DIR            user executables [EPREFIX/bin]
  --sbindir=DIR           system admin executables [EPREFIX/sbin]
  --libexecdir=DIR        program executables [EPREFIX/libexec]
  --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
  --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
  --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
  --libdir=DIR            object code libraries [EPREFIX/lib]
  --includedir=DIR        C header files [PREFIX/include]
  --oldincludedir=DIR     C header files for non-gcc [/usr/include]
  --datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]
  --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
  --infodir=DIR           info documentation [DATAROOTDIR/info]
  --localedir=DIR         locale-dependent data [DATAROOTDIR/locale]
  --mandir=DIR            man documentation [DATAROOTDIR/man]
  --docdir=DIR            documentation root [DATAROOTDIR/doc/PACKAGE]
  --htmldir=DIR           html documentation [DOCDIR]
  --dvidir=DIR            dvi documentation [DOCDIR]
  --pdfdir=DIR            pdf documentation [DOCDIR]
  --psdir=DIR             ps documentation [DOCDIR]

Optional Packages:
  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
  --without-warning       run perl as perl without -w
  --with-fmlconfdir=DIR   use DIR instead of SYSCONFDIR/fml
  --with-mlspooldir=DIR   use DIR instead of /var/spool/ml
  --with-fml-owner=USER   use USER instead of fml
  --with-fml-group=GROUP  use GROUP instead of fml
  --with-default-domain=DOMAIN     use DOMAIN as the default ML domain
  --with-default-hostname=HOSTNAME use HOSTNAME as the default hostname
  --without-mime-component-filter  disable mime_component_filter
  --with-group-writable-fmlconfdir=DIR   instead of \$fmlconfdir/config.gw
  --with-ml-home-prefix-map=PATH   use PATH as primary_ml_home_prefix_map
  --with-group-writable-ml-home-prefix-map
</screen>

</para>


<sect2>
	<title>
	例: configure の実行
	</title>

<para>
例: NetBSD では /usr/pkg 以下へインストール。
<screen>
% ./configure --prefix=/usr/pkg
</screen>
</para>


<para>
例: FreeBSD の場合、/usr/local 以下へインストール(デフォルトのまま)。
<screen>
% ./configure
</screen>
</para>

<para>
例:	main.cf の置き場所として
	/etc/fml を使うなら、こうする(Debian であれば、こうするべき？)。
<screen>
#  ./configure --with-fmlconfdir=/etc/fml
checking for perl... perl
checking for perl... /usr/bin/perl
"checking whether optional useful commands are available or not"
checking for cc... /usr/bin/cc
checking for install... /usr/bin/install
checking for cksum... /usr/bin/cksum
checking for sum... /usr/bin/sum
checking for md5... /usr/bin/md5
checking for digest... /usr/bin/digest
checking for ls... /bin/ls
checking for tar... /bin/tar
checking for gzip... /usr/bin/gzip
checking for zcat... /usr/bin/zcat
checking for gzcat... /usr/bin/gzcat
checking for gunzip... /usr/bin/gunzip
checking for lha... no
checking for ish... no
checking for bzip2... /usr/bin/bzip2
checking for bunzip2... /usr/bin/bunzip2
checking for uuencode... /usr/bin/uuencode
checking for compress... /usr/bin/compress
checking for sendmail... /usr/sbin/sendmail
checking for makemap... no
checking for newaliases... /usr/bin/newaliases
checking for postfix... /usr/sbin/postfix
checking for postalias... /usr/sbin/postalias
checking for postconf... /usr/sbin/postconf
checking for postmap... /usr/sbin/postmap
checking for nkf... /usr/bin/nkf
checking for kakasi... no
checking for namazu... no
checking for pgp... /usr/bin/pgp
checking for pgp5... /usr/bin/pgp5
checking for pgpe... /usr/bin/pgpe
checking for pgpk... /usr/bin/pgpk
checking for pgps... /usr/bin/pgps
checking for pgpv... /usr/bin/pgpv
checking for gpg... /usr/bin/gpg
checking for gpgv... /usr/bin/gpgv
checking for gpgsplit... /usr/bin/gpgsplit
checking for less... /usr/bin/less
checking for more... /usr/bin/more
checking for w3m... /usr/bin/w3m
checking for spamassassin... no
checking for spamd... no
checking for spamc... no
checking for bogofilter... no
checking for clamscan... /usr/bin/clamscan
checking for vi... /usr/bin/vi
checking for ng... /usr/bin/ng
checking for mule... /usr/bin/mule
checking for emacs... no
checking for xemacs... no
configure: creating ./config.status
config.status: creating install.pl
config.status: creating config.sh
config.status: creating fml/etc/install.cf
config.status: creating fml/etc/main.cf
config.status: creating fml/etc/default_config.cf.ja
config.status: creating fml/etc/default_config.cf.en
config.status: creating fml/etc/site_default_config.cf
config.status: creating fml/libexec/loader
config.status: creating fml/bin/fmladdr
config.status: creating fml/bin/fmlalias
config.status: creating fml/bin/fmlconf
config.status: creating fml/bin/fmldoc
config.status: creating fml/bin/fmlhtmlify
config.status: creating fml/bin/fmlsch
config.status: creating fml/bin/fmlproj
config.status: creating fml/bin/fmlpgp
config.status: creating fml/bin/fmlpgp5
config.status: creating fml/bin/fmlpgpe
config.status: creating fml/bin/fmlpgpk
config.status: creating fml/bin/fmlpgps
config.status: creating fml/bin/fmlpgpv
config.status: creating fml/bin/fmlgpg
config.status: creating fml/bin/fmlgpgv
config.status: creating fml/bin/fml
config.status: creating fml/bin/makefml
enabled: perl -w

fml has been configured with the following options:

                    prefix: /usr/local
               exec_prefix: ${prefix}
                    bindir: ${exec_prefix}/bin
                   sbindir: ${exec_prefix}/sbin
                   lib_dir: ${exec_prefix}/lib
               libexec_dir: ${exec_prefix}/libexec
                    mandir: ${datarootdir}/man
               datarootdir: ${prefix}/share
                   datadir: ${datarootdir}
   
         fml process owner: fml
         fml process group: fml
                fmlconfdir: /etc/fml
        ml_home_prefix_map: /etc/fml/ml_home_prefix
                mlspooldir: /var/spool/ml
            default domain: home.fml.org
          default hostname: elena.home.fml.org
   
         mime based filter: yes
   
Now you must run "make install" as user "root".

</screen>
</para>

<para>
補足: いや、こういうタイプの設定をする OS の場合
/usr/local ではなく /usr 直下に入れるのでしょうか？
その場合は、次のように指定してください。
<screen>
# ./configure --prefix=/usr --with-fmlconfdir=/etc/fml
</screen>
</para>

</sect2>

</sect1>


<!-- ====================================================== -->
<!--
   XXX-TODO 各ディレクトリの役割は別ファイルへ？
-->
<sect1>
	<title>
	補足: 各ディレクトリの役割
	</title>

<para>
それぞれのディレクトリの役割は次の通りです。
なお、デフォルトでは /usr/local 以下にインストールされます。
</para>

<para>
  <table>
    	<title>
	ディレクトリの構造
	</title>

    <tgroup cols=2>

      <thead>
        <row>
          <entry> ディレクトリ 		</entry>
          <entry> 説明			</entry>
        </row>
      </thead>

      <tbody>
        <row>
          <entry> /usr/local/etc/fml	</entry>
          <entry>
	基本設定ファイルを置く場所。
	&fml4; の
	/usr/local/fml/.fml や default_config.ph を置く場所に相当します。
	/usr/local/etc/fml/main.cf では、
	使用する &fml8; のバージョンやライブラリの場所(ディレクトリ)
	などが指定可能です
	(【重要】
	バージョンアップして問題があった場合には、
	バージョン変数を編集することで、
	すぐに古いバージョンへの切り戻しが可能です)。
          </entry>
        </row>

        <row>
          <entry> /usr/local/libexec/fml 		</entry>
          <entry>
	実行ファイル ( &fml4; の /usr/local/fml 相当)
	  </entry>
        </row>

        <row>
            <entry>
		/usr/local/lib/fml
	  </entry>
          <entry>
	perl モジュール群を置く場所 ( &fml4; の /usr/local/fml 相当)
	  </entry>
        </row>

        <row>
          <entry>
		/usr/local/share/fml
	  </entry>
          <entry>
	メッセージなどのテンプレートを置く( &fml4; の 
		/usr/local/fml/messages/ 相当)。
	この下に言語依存のサブディレクトリが作られます。
	  </entry>
        </row>

        <row>
          <entry>
		/var/spool/ml
	  </entry>
          <entry>
		デフォルトドメインのＭＬ群のトップディレクトリ。
		&fml4; と同じ目的で使われます。

		注意: /var/spool/ml のオーナは configure で指定した
		owner 変数(デフォルトはユーザ fml)に設定されます。

		なお、ドメインごとに別の prefix を用意して下さい。
		たとえば fml.org 用は /var/spool/ml で、
		nuinui.net 用には /var/spool/nuinui.net などのように。
		このドメインとディレクトリの対応関係は
		ml_home_prefix_maps (
			<link linkend="virtualdomain.fml8.overview">
			バーチャルドメインの節
			</link>
			を参照
		)に記述します(
		makefml/fml の newdomain コマンドで設定されます)。

		バーチャルドメインの詳細は
		<link linkend="virtualdomain">
		<xref linkend="virtualdomain">
		</link>
		を参照して下さい。
	  </entry>
        </row>
      </tbody>

    </tgroup>
  </table>
</para>
</sect1>


<!-- ====================================================== -->
<sect1 id="install.fml.unix.makeinstall">
	<title>
	fml のインストール: make install
	</title>

<para>
configure を実行後、ユーザ root になり、make install を実行して下さい。 
<screen>
% su root
# make install
</screen>
</para>

<warning>
<para>
configure はユーザ root で実行する必要はありませんが、
make install は必ずユーザ root で実行して下さい。
<screen>
% su root
# ./configure
# make install
</screen>
間違えないように、はじめから 
configure も root で実行するほうがいいのかもしれません。
</para>
</warning>

</sect1>


<sect1 id="install.fml.unix.edit.main.cf">
	<title>
	main.cf を編集する
	</title>

<para>
必要なら /usr/local/etc/fml/main.cf を編集して下さい。

configure が、あなたの環境に合わせて main.cf を書換えしているはずなので 
configure のオプション指定が正しければ、編集の必要は、まずないはずです。
</para>

<para>
mani.cf は大枠の最も基本的な設定です。
より細かな設定、
たとえばサイト共通の fml の動作指定などは site_default_config.cf の役割です。
各ＭＬ固有の設定は、
各ＭＬのホームディレクトリにある config.cf ファイルを編集して下さい。
</para>

<para>
逆にいえば、特定のメーリングリストで優先される順は次のようになります。
<screen>
$ml_home_dir/config.cf
site_default_config.cf
main.cf
</screen>
</para>

<!-- main.cf の見本 -->
&sect.main.cf;

</sect1>


<sect1 id="install.fml.unix.edit.site.default.config.cf">
	<title>
	site_default_config.cf を編集する (オプション)
	</title>

<para>
/usr/local/etc/fml/site_default_config.cf  は、
そのホスト共通の設定ファイル
<footnote>
<para>
これは &fml4; の site_force.ph に相当するものです。
</para>
</footnote>
です。必要に応じて編集してください。
</para>

<para>
もちろん、
この設定より、
各ＭＬの設定(例: /var/spool/ml/elena/config.cf)が優先されます。
</para>

<para>
デフォルトでは &fml4; と合わせるために、
および見本として:)
subject のタグをつけない設定とフィルタ関連の設定だけが入っています。
<screen>
# $FML: fml_on_unix.sgml,v 1.13 2008/08/18 13:21:42 fukachan Exp $
#
#               site default_config.cf EXAMPLE
#
# fml-devel loads .cf files in this order for elena ML.
#      1. ${prefix}/etc/fml/defaults/$VERSION/default_config.cf
#      2. ${prefix}/etc/fml/site_default_config.cf
#      3. ${prefix}/etc/fml/domains/$DOMAIN/default_config.cf
#      4. /tmp/dir/elena/config.cf
#
# This file overrides the default "default_config.cf" configurations
# in the following way.
#

# We want to disable the subject tag in articles by default.
article_header_rewrite_rules	-=	rewrite_article_subject_tag

# mime based comonent filter
use_mime_component_filter	=	yes


# [site specific options]
#   Example:
#	key  = value
#	key += value
#	key -= value


=cut

#
# you can write hooks here after.
#   Example:
#	$distribute_run_start_hook = q{ ... };
</screen>
</para>

</sect1>


<sect1>
	<title>
	フィルタをどうするか？
	</title>

<para>
デフォルトではすべてのフィルタが有効です。
&fml4; の推奨設定に相当しています。
</para>

<para>
「フィルタのかけすぎ」という見解もあるかもしれませんが、
あえてデフォルトは厳しい設定にしてあります。
</para>

<para>
フィルタが、かかっているのはよいのですが、
mime component filter のデフォルトをどうすれば良いのかは基準が曖昧です。
デフォルトでは、
ＭＬへの投稿が許されるのは text/plain のメールのみとしてあります。
これで text/html で送ってくる寝ぼけたメールも、
添付ファイルで送られてくるウィルスもデフォルトでは通りません。
</para>

<para>
なお、(すべてのＭＬで)
mime component filter を無効にするには
site_default_config.cf で
<screen>
use_mime_component_filter	=	no
</screen>
としてください。
</para>

<para>
mime component filter を有効にしたいがルールをカスタマイズしたいという場合、
site_default_config.cf では
<screen>
use_mime_component_filter	=	yes
</screen>
のままにして、
/usr/local/etc/fml/mime_component_filter 
をカスタマイズしてください。
</para>

<warning>
<para>
ただ、仕事のメールで添付ファイルなしは厳しいようなので、
社内向けメールなど仕事用のＭＬサーバとして使うなら、
インストール後、すぐに
<screen>
[/usr/local/etc/fml/site_default_config.cf]

use_mime_component_filter	=	no
</screen>
に変更しておくとよいでしょう。
</para>
</warning>

</sect1>


<sect1 id="install.virtual">
	<title>
	バーチャルドメインの場合
	</title>

<para>
最初に(つまり、そのドメインでＭＬを作る前に)、
newdomain コマンドで 
ml_home_prefix_maps に利用したいドメインと
ml_home_prefix の対応関係を定義してください。
<screen>
[/var/spool/ml/etc/fml/ml_home_prefix]

nuinui.net /var/spool/nuinui.net
</screen>
newdomain コマンドについては
<link linkend="setup.newml">
「ＭＬの作成」
</link>
の節で後述します。
</para>

<warning>
<para>
ml_home_prefix_maps のパスを変更したい場合は
/usr/local/etc/fml/main.cf を編集して下さい
(もっとも、たいてい、編集は不要です)。
</para>

<para>
なお、
site_default_config.cf は、
ドメインに関わらず適用されることに注意してください。
つまり、この設定はバーチャルドメインにも適用されます。
</para>
</warning>

</sect1>


<!-- メールサーバの設定 -->
&sect.install.postfix;
&sect.install.qmail;

<!-- recipes -->
<sect1 id="install.recipes">
	<title> 
	レシピ’s
	</title> 

	<!-- TABLE_OF_RECIPES -->
	&sect.install.recipes;
</sect1>

</chapter>
