Postfixのインストール [Debian]
2008/03/21 Fri [Edit]
【環境】
coLinux0.7
Debian GNU/Linux 4.0
0.Postfixとは
sendmailとの互換性を保ちながら、運用管理の簡易化やパフォーマンス、セキュリティの強化が図られているMTA(Mail Transfer Agent)=SMTPサーバーです。
公式:The Postfix Home Page
参考:ソースコードからの Postfix インストール
1.アカウントとグループの作成
ユーザー、グループ"postfix"とグループ"postdrop"を作成
| # adduser
--system --group --no-create-home postfix # addgroup --system postdrop |
| adduserのオプション | |
| --system | システムユーザー(ログインできないユーザー)を作成する。 |
| --group | "--system"と併用することによって同じ名前でグループが作成される。 "--system"を併用しないと、グループが作成されるだけ。ユーザーは作成されない。 |
| --no-create-home | ホームディレクトリを作らない |
2.ソースのDL 〜 make
| $ wget ftp://postfix.get7.biz/postfix/official/postfix-2.5.1.tar.gz $ tar zxvf postfix-2.5.1.tar.gz $ cd postfix-2.5.1 $ make |
※インクルードファイルにdb.hが見つからないと以下のようなエラーになります。
| make -f Makefile.in
MAKELEVEL= Makefiles (echo "# Do not edit -- this file documents how Postfix was built for your machine."; /bin/sh makedefs) >makedefs.tmp No <db.h> include file found. Install the appropriate db*-devel package first. See the RELEASE_NOTES file for more information. make: *** [Makefiles] エラー 1 make: *** [Makefiles] エラー 2 |
私の場合は、そもそもdb.h自体が存在しなかったので、Berkeley DBをインストールしました。
また、BerkeleyDBのインストール先が/usr/local/BerkeleyDB.4.6/配下になるので、インクルードファイルやライブラリを見える場所にもってくるか、makefileなどでパスを指定する必要があります。
今回は、ライブラリは/etc/ld.so.confに追加(上記リンクBerkeley DBをインストール参照)し、インクルードファイルは直接コピーしてしまいました。
cp /usr/local/BerkeleyDB.4.6/include/db.h /usr/include/
今度は下記のようなwarningが出ましたが、無視してよいワーニングらしいです。
| gcc -Wmissing-prototypes
-Wformat -DHAS_DB -I/usr/local/BerkeleyDB.4.6/include -g -O -I. -I../../include
-DLINUX2 -c trace.c In file included from trace.c:86: ../../include/sys_defs.h:705:1: warning: "HAS_DB" redefined <command line>:1:1: warning: this is the location of the previous definition |
3.インストール
既に別のsendmailがインストールされている場合は、退避もしくは削除しておく必要があります。
参考
私は削除しておかなかったので、起動時に怒られてしまいました^^;
色々聞かれますが、全てデフォルトでよいのでEnter。
| # make
install install_root: [/] tempdir: [/home/onion/src/postfix-2.5.1] config_directory: [/etc/postfix] command_directory: [/usr/sbin] daemon_directory: [/usr/libexec/postfix] data_directory: [/var/lib/postfix] html_directory: [no] mail_owner: [postfix] mailq_path: [/usr/bin/mailq] manpage_directory: [/usr/local/man] newaliases_path: [/usr/bin/newaliases] queue_directory: [/var/spool/postfix] readme_directory: [no] sendmail_path: [/usr/sbin/sendmail] setgid_group: [postdrop] Warning: you still need to edit myorigin/mydestination/mynetworks parameter settings in /etc/postfix/main.cf. See also http://www.postfix.org/STANDARD_CONFIGURATION_README.html BTW: Check your /etc/aliases file and be sure to set up aliases |
ちなみにpostfixの設定ファイルは以下の通り。
基本設定ファイル
/etc/postfix/main.cf
各種デーモンの設定ファイル
/etc/postfix/master.cf
4.起動してみる
| # postfix
start postfix/postfix-script: warning: /usr/lib/sendmail and /usr/sbin/sendmail differ postfix/postfix-script: warning: Replace one by a symbolic link to the other postfix/postfix-script: starting the Postfix mail system |
なにやら怒られました。。
/usr/lib/sendmailがexim4へのシンボリックリンクになっていました。
lrwxrwxrwx 1 root root 13 2008-02-16 12:27 sendmail -> ../sbin/exim4
ちなみにexim4はDebian 標準のメールサーバです。
というわけで、
・シンボリックリンクの張りなおし
・exim4のアンインストール
・exim4の自動起動スクリプト削除
をします。
シンボリックリンク張替え # cd /usr/lib # rm /usr/lib/sendmail # ln -s ../sbin/sendmail sendmail アンインストール # aptitude remove exim4 exim4の自動起動スクリプト削除 # rm /etc/init.d/exim4 # update-rc.d exim4 remove Removing any system startup links for /etc/init.d/exim4 ... /etc/rc0.d/K20exim4 /etc/rc1.d/K20exim4 /etc/rc2.d/S20exim4 /etc/rc3.d/S20exim4 /etc/rc4.d/S20exim4 /etc/rc5.d/S20exim4 /etc/rc6.d/K20exim4 |
update-rc.dについては、こちらのエントリーの下の方を参照。
4.起動スクリプト作成
# vi /etc/init.d/postfix
#!/bin/sh PID=`/bin/ps -aef | /bin/grep postfix | /bin/grep master | /bin/grep -v grep | /usr/bin/awk '{print $2}'` case "$1" in 'stop') 'reload') 'abort') 'flush') 'status') *) esac |
自動起動スクリプトの追加
# update-rc.d postfix defaults
5.起動〜動作確認
エイリアスの設定
# newaliases
/etc/aliasesを設定することによってメールアドレスの別名を利用できます。
例えば、postmaste宛のメールをrootで受け取るには以下のように記述します。
postmaster: root
aliasesファイルの設定を有効にするには、newaliasesコマンドを使います。
このコマンドを使用するとsendmail(Postfix)が参照するバイナリデータベース(/etc/aliases.db)が/etc/aliasesを元に更新されます。
起動
# /etc/init.d/postfix start
telnetで確認(ローカルホストのポート25)
| #colinux2:/etc#
telnet localhost 25 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. 220 GreenOnions ESMTP Postfix helo hogehoge ※入力開始 # 送り側のホスト・ドメイン名を入力 250 GreenOnions mail from: aaa ※差出人エンベロープアドレスを入力 250 2.1.0 Ok rcpt to: XXXXXXXX@aaaaa.co.jp ※送信先エンベロープアドレスを入力 250 2.1.5 Ok data 354 End data with <CR><LF>.<CR><LF>※メッセージデータの開始(以下、メーラーで通常見える部分) From: hogehoge@hoge.co.jp ※メールヘッダ 差出人を入力<Enter> To: XXXXXXXX@aaaaa.co.jp ※メールヘッダ 宛先を入力 この指定ないと「undisclosed-recipients:;」になったりする Subject: TEST ※メールヘッダ件名を入力<Enter> ※本文入力 HAHAHAHA
|
送信先エンベロープアドレスにメールが届けば成功です。
rcpt to:さえちゃんと入れていればメールは届くんですね!
![]() | Postfix実用ガイド (2004/08) カイル・D. デント 商品詳細を見る |
Comments
Track Backs
TB URL





