久々にPoxtfixのインストールをしたら、色々変わりすぎていて、コンパイル・インストールする時に大ハマりしたのでメモです。
ちなみにこの記事で説明する手順は、ICU(http://site.icu-project.org/)、OpenSSLが既にインストールされていて、以下のディレクトリ構成になっている事を前提としています。
1 2 3 4 5 6 7 8 9 10 11 12 13 | /var/home/ap/lib+ | +---icu+ | | | +---include | | | +---lib +---openssl+ | +---include+ | | | +---openssl +---lib |
まずは、使用しているCPUのアーキテクチャを調べます。
*コンパイルパラメータとして使用するので、メモって下さい。
gcc -c -Q -march=native --help=target (中略) -march= corei7-avx ←これです (中略)
既にyumでPostfixがインストールされている場合は、サービスの停止、sendmailファイルのリネームを行います。
systemctl stop postfix.service systemctl disable postfix.service
mv /usr/sbin/sendmail /usr/lib/sendmail.org mv /usr/lib/sendmail /usr/lib/sendmail.org
各ディレクトリ・シンボリックリンクを作成します。
*LD_LIBRARY_PATHで設定したパスが通らないので、あらかじめシンボリックリンクを作成する事で、コンパイルエラーと実行時エラーを回避します。
mkdir /var/home/ap/postfix mkdir /var/home/ap/postfix/lib cd /var/home/ap/postfix/lib ln -s /var/home/lib/openssl/lib/libssl.so.1.0.0 libssl.so.1.0.0 ln -s /var/home/lib/openssl/lib/libcrypto.so.1.0.0 libcrypto.so.1.0.0 ln -s /var/home/lib/icu/lib/libicui18n.so.58 libicui18n.so.58 ln -s /var/home/lib/icu/lib/libicuuc.so.58 libicuuc.so.58 ln -s /var/home/lib/icu/lib/libicudata.so.58 libicudata.so.58
Postfixで使用するグループ、ユーザを作成します。
*既にPostfixがインストールされている環境では不要です。
groupadd postdrop groupadd postfix useradd -g postfix -d /var/home/ap/postfix/queue -s /sbin/nologin postfix
ソースのダウンロード、展開をします。
wget "http://mirror.postfix.jp/postfix-release/official/postfix-3.2.0.tar.gz" tar xvfz postfix-3.2.0.tar.gz cd cd postfix-3.2.0
コンパイルします。
make makefiles \ shared=yes \ dynamicmaps=yes \ command_directory=/var/home/ap/postfix/bin \ config_directory=/var/home/ap/postfix/etc \ daemon_directory=/var/home/ap/postfix/libexec \ data_directory=/var/home/ap/postfix/data \ mailq_path=/var/home/ap/postfix/bin/mailq \ manpage_directory=/var/home/ap/postfix/man \ meta_directory=/var/home/ap/postfix/etc \ newaliases_path=/var/home/ap/postfix/bin/newaliases \ openssl_path=/var/home/lib/openssl/bin/openssl \ queue_directory=/var/home/ap/postfix/queue \ sendmail_path=/var/home/ap/postfix/bin/sendmail \ shlib_directory=/var/home/ap/postfix/lib \ OPT='-O2 -march=corei7-avx -mtune=corei7-avx -fno-strict-aliasing' \ CCARGS='-DHAS_SSL -DUSE_TLS -DHAS_PCRE -I/var/home/lib/openssl/include/openssl -I/var/home/lib/icu/include' \ AUXLIBS='-L/var/home/lib/openssl/lib -lssl -lcrypto -L/var/home/lib/icu/lib/ -licui18n -licuuc -licudata -lpcre -ldl -lz' make
インストールをします。
make install *ほとんど、デフォルト設定で行けるかと思いますが、「/var/home/ap/postfix/tmp」だけデフォルト値から変更します。 (中略) Please specify the prefix for installed file names. Specify this ONLY if you are building ready-to-install packages for distribution to OTHER machines. See PACKAGE_README for instructions. install_root: [/] Please specify a directory for scratch files while installing Postfix. You must have write permission in this directory. tempdir: [/var/home/src/postfix-3.2.0] /var/home/ap/postfix/tmp Please specify the final destination directory for installed Postfix configuration files. config_directory: [/var/home/ap/postfix/etc] Please specify the final destination directory for installed Postfix administrative commands. This directory should be in the command search path of adminstrative users. command_directory: [/var/home/ap/postfix/bin] Please specify the final destination directory for installed Postfix daemon programs. This directory should not be in the command search path of any users. daemon_directory: [/var/home/ap/postfix/libexec] Please specify the final destination directory for Postfix-writable data files such as caches or random numbers. This directory should not be shared with non-Postfix software. data_directory: [/var/home/ap/postfix/data] Please specify the final destination directory for the Postfix HTML files. Specify "no" if you do not want to install these files. html_directory: [no] no Please specify the owner of the Postfix queue. Specify an account with numerical user ID and group ID values that are not used by any other accounts on the system. mail_owner: [postfix] Please specify the final destination pathname for the installed Postfix mailq command. This is the Sendmail-compatible mail queue listing command. mailq_path: [/var/home/ap/postfix/bin/mailq] Please specify the final destination directory for the Postfix on-line manual pages. You can no longer specify "no" here. manpage_directory: [/var/home/ap/postfix/man] Please specify the final destination pathname for the installed Postfix newaliases command. This is the Sendmail-compatible command to build alias databases for the Postfix local delivery agent. newaliases_path: [/var/home/ap/postfix/bin/newaliases] Please specify the final destination directory for Postfix queues. queue_directory: [/var/home/ap/postfix/queue] Please specify the final destination directory for the Postfix README files. Specify "no" if you do not want to install these files. readme_directory: [no] no Please specify the final destination pathname for the installed Postfix sendmail command. This is the Sendmail-compatible mail posting interface. sendmail_path: [/var/home/ap/postfix/bin/sendmail] Please specify the group for mail submission and for queue management commands. Specify a group name with a numerical group ID that is not shared with other accounts, not even with the Postfix mail_owner account. You can no longer specify "no" here. setgid_group: [postdrop] Please specify the final destination directory for Postfix shared-library files. shlib_directory: [/var/home/ap/postfix/lib] Please specify the final destination directory for non-executable files that are shared among multiple Postfix instances, such as postfix-files, dynamicmaps.cf, as well as the multi-instance template files main.cf.proto and master.cf.proto. meta_directory: [/var/home/ap/postfix/etc] (中略)
sendmailファイルへのシンボリックリンク作成、パーミッションの変更をします。
ln -s /var/home/ap/postfix/bin/sendmail /usr/sbin/sendmail ln -s /var/home/ap/postfix/bin/sendmail /usr/lib/sendmail chgrp -h postfix /usr/sbin/sendmail chgrp -h postfix /usr/lib/sendmail chgrp postfix /var/home/ap/postfix/bin/sendmail chmod g+s /var/home/ap/postfix/bin/sendmail
自動起動させるためのUnitファイルを作成します。
*既にPostfixがインストールされている場合は、ファイル名を変えて下さい。 *ファイル作成後、「systemctl daemon-reload」を実行して下さい。 view /usr/lib/systemd/system/mypostfiix.service [Unit] Description=Postfix Mail Transport Agent After=syslog.target network.target [Service] Type=forking PIDFile=/var/home/ap/postfix/queue/pid/master.pid ExecStart=/var/home/ap/postfix/bin/postfix start ExecReload=/var/home/ap/postfix/bin/postfix reload ExecStop=/var/home/ap/postfix/bin/postfix stop [Install] WantedBy=multi-user.target
サービスを開始します。
systemctl enable mypostfiix.service systemctl start mypostfiix.service
下記プロセスが表示されていれば、正しくインストールできています。
root 15147 1 0 3月29 ? 00:00:00 /var/home/ap/postfix/libexec/master -w postfix 15149 15147 0 3月29 ? 00:00:00 qmgr -l -t unix -u postfix 19203 15147 0 14:22 ? 00:00:00 pickup -l -t unix -u
設定は、またの機会という事で・・・以上で完了となります。
ここまで読んで頂きありがとうございます。
現在、ランキング参加中です。良ければランキングボタンをクリック願います。
↓↓↓↓↓↓↓↓
オープンソースランキング