0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

RockyLinux9.6 PostfixAdmin構築メモ(事前準備)

Last updated at Posted at 2025-08-08

概要

PostfixAdminを動かすための、事前準備作業
・ssh設定変更
・Apache/Postfix/Dovecotインストール
・firewall設定

環境

RockyLinux9.6(さくらのクラウド)
PostfixAdmin(3.3.15) - Sqlite

参考URL

https://www.server-memo.net/centos-settings/firewalld/add-service.html
https://www.tama-negi.com/2024/05/25/linux-nslookup-dig/

作業

ssh設定変更

  • port変更(22 -> 2222)
  • パスワード認証 -> 公開鍵認証
  • などなど

公開鍵認証部分の説明は、ここでは省略します。
公開鍵を設定しないで、sshサービスを再起動するとログインできなくなる場合がありますのでご注意ください。
(さくらのクラウドの場合は、コンソール機能があるので、間違えても大丈夫!!)
https://manual.sakura.ad.jp/cloud/server/console.html

vi /etc/ssh/sshd_config.d/custom.conf (新規作成)
---
Port 2222

LoginGraceTime 2m
PermitRootLogin no
StrictModes yes
MaxAuthTries 3
MaxSessions  5
DenyUsers toor administrator administrateur admin adm test testuser guest info mysql user oracle

PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys

IgnoreRhosts yes

PasswordAuthentication no
PermitEmptyPasswords no
---

/etc/ssh/sshd_configを編集しないで、有効にしたいものだけを記述

Firewallの設定追加

cp /lib/firewalld/services/ssh.xml /etc/firewalld/services/
vi /etc/firewalld/services/ssh.xml
---
  <port protocol="tcp" port="22"/>
</service>
↓
  <port protocol="tcp" port="22"/>
  <port protocol="tcp" port="2222"/>
</service>
---

標準port22に加え、port2222を許可するため、1行追加
(もし、SSHを標準port設定を戻した際に、困らないために残しておく)

ssh設定反映

firewall-cmd --reload
systemctl restart sshd

SWAP追加

以下を参考に追加。
https://manual.sakura.ad.jp/vps/os-packages/add-swapfile.html
ここでは、説明を省略

postfix インストール

dnf install postfix postfix-sqlite

dovecot インストール

dnf install dovecot

apache インストール

dnf install httpd mod_ssl

php インストール

事前準備。もしインストールされているPHPがあればすべて削除

dnf remove php php-*

remi経由でPHPインストール 8.3

dnf install dnf-utils http://rpms.remirepo.net/enterprise/remi-release-9.rpm
dnf module reset php
dnf module enable php:remi-8.3
dnf install php php-mbstring php-imap

自動起動設定

systemctl enable postfix
systemctl enable dovecot
systemctl enable httpd

Firewall設定追加

http: Let's Encrypt認証用
https: postfixadmin用
smtp,submission(587),imaps:メール関連(今回、pop3は使わない)

#設定追加
firewall-cmd --add-service=http --zone=public --permanent
firewall-cmd --add-service=https --zone=public --permanent

firewall-cmd --add-service=smtp --zone=public --permanent
firewall-cmd --add-service=smtp-submission --zone=public --permanent

firewall-cmd --add-service=imaps --zone=public --permanent

## 設定反映
firewall-cmd --reload

## 確認
firewall-cmd --list-all

Let's Encryptを動かすための関連ソフトインストール

dnf --enablerepo=epel install certbot

#証明書を自動更新するようにする。
systemctl enable --now certbot-renew.timer

逆引き設定

メールサーバとして利用する場合、逆引き設定した方がいいです。
さくらのクラウドの場合、以下のページを参考にしてください。
https://manual.sakura.ad.jp/cloud/server/reverse-hostname.html

# 逆引き確認
dig -x IP_ADDR

意識高い系?メールサーバでは、IPの逆引きが出来ないメールサーバは拒否する設定が入っている事があります。
こんなエラーを出して、メールを届けてもらえません。
悪いメールサーバでないことを示すためにも逆引き設定はオススメです。

Aug  5 11:20:22 mail-server postfix/smtpd[2865]: NOQUEUE: reject: RCPT from unknown[xxx.xxx.xxx.xxx]: 450 4.7.25 Client host rejected: cannot find your hostname, [xxx.xxx.xxx.xxx]; from=<hoge@xxx.com> to=<hoga@yyy.com> proto=ESMTP helo=・・・・

その他ソフト

すでに入っている場合は、飛ばしてください。

dnf install wget
dnf install bind-utils
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?