備忘録

CentOS7に最新のPostfix3.4をインストール

CentOS7のデフォルトでは2.10.1とバージョンが古いので、GhettoForgeリポジトリを使ってPostfix3.4.6をインストールした時のメモ

CentOS7の公式yumリポジトリで提供されているバージョン

# yum info postfix

利用可能なパッケージ
名前                : postfix
アーキテクチャー    : x86_64
エポック            : 2
バージョン          : 2.10.1
リリース            : 7.el7
容量                : 2.4 M
リポジトリー        : base/7/x86_64
要約                : Postfix Mail Transport Agent
URL                 : http://www.postfix.org
ライセンス          : IBM and GPLv2+
説明                : Postfix is a Mail Transport Agent (MTA), supporting LDAP, SMTP AUTH (SASL),
                    : TLS

Postfixがすでにインストールされていたら削除

Postfixインストール確認

# yum list installed | grep postfix

Postfixの停止

# systemctl stop postfix.service

Postfixの削除

# yum remove postfix

GhettoForgeリポジトリの追加

最新のPostfixをインストールするのにGhettoForgeリポジトリを使います。

GhettoForge(http://ghettoforge.org/index.php/Usage)

# yum install http://mirror.ghettoforge.org/distributions/gf/gf-release-latest.gf.el7.noarch.rpm

GhettoForgeリポジトリの無効化

GhettoForgeリポジトリは、インストールすると有効化の状態になっています。必要な時だけGhettoForgeリポジトリを使いたいので無効化にします。

/etc/yum.repos.d/gf.repo

enabled=1
↓
enabled=0

GhettoForgeリポジトリを無効化にしたので、使用する時は「--enablerepo=gf-plus」といったように明示的に実行します。

最新のPostfixインストール

# yum --enablerepo=gf-plus install postfix3

インストールが完了したらバージョンを確認

# postconf | grep mail_version

mail_version = 3.4.6

Postfixを起動

# systemctl start postfix.service

Postfixの自動起動の設定

# systemctl enable postfix.service

libmysqlclient.so.18 でエラー

Postfixのインストールでlibmysqlclient.so.18のエラーが発生した場合の対処方法

MySQLを使用するのに、MariaDBを削除した場合に発生するようです。

MySQL・Postfixを一度、削除してから入れなおします。

サービス停止
# systemctl stop mysqld.service
# systemctl stop postfix.service

アンインストール
# yum remove mysql*
# yum remove mysql-*
# yum remove postfix

デフォルト(CentOS7)のPostfixをインストール
# yum install postfix

最新のMySQL8インストール
# yum --enablerepo=mysql80-community install mysql-community-server
(※本サイトの「CentOS7にMySQL公式リポジトリを使って最新のMySQL8.0をインストール」を参照ください)

デフォルト(CentOS7)のPostfixをアンインストール
# yum remove postfix

最新のPostfix3をインストール
# yum --enablerepo=gf-plus install postfix3

libmysqlclient.so.18がインストールされているか確認
# find / -name libmysqlclient.so.*
/usr/lib64/mysql/libmysqlclient.so.18
/usr/lib64/mysql/libmysqlclient.so.18.1.0

Postfixの主なコマンド

状態確認
# systemctl status postfix.service

起動
# systemctl start postfix.service

停止
# systemctl stop postfix.service

再起動
# systemctl restart postfix.service

自動起動設定状態の確認
# systemctl is-enabled postfix.service

自動起動設定
# systemctl enable postfix.service

自動起動解除
# systemctl disable postfix.service

設定ファイルチェック
# postfix check

メールキュー確認
# postqueue -p

メールキュー削除
# postsuper -d [キューID]

メールキュー全削除
# postsuper -d ALL

メールキュー再送信
# postfix flush