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構築メモ(Apache/Postfixadmin)

Posted at

概要

Let's Encryptのインストール
PostfixAdminの初期セットアップし、管理画面が立ちあげる。

環境

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

参考URL

https://www.gin-iro.work/mizuito/tec/centos/postfixadmin_postfix_dovecot_sqlite.htm
https://qiita.com/shadowhat/items/c194d2b6e589fc937106
https://www.rouge.gr.jp/~fuku/tips/postfixadmin/

事前作業

作業概要

サンプル設定 ここで使うドメイン一覧(仮)

URL or ホスト名
postfixadminの管理画面 https://admin.xxx.com/
メールサーバのホスト名 mail.xxx.com
postfixadminへ設定するドメイン① xxx.com
postfixadminへ設定するドメイン② app.xxx.com
postfixadminへ設定するドメイン③ blog.xxx.com

Apache設定

  • port80用の設定(http)
  • postfixadmin用の設定(https)
cp -p /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf_org
vi /etc/httpd/conf/httpd.conf
以下を書き換え
---
#ServerName www.example.com:80
↓
ServerName mail.xxx.com:80
---

port80の設定
(個人的な好み、postfixadminがhttpでアクセスされないように。。)

mkdir /var/www/html/default_80
vi /etc/httpd/conf.d/vhosts_80.conf
---
# Default port 80
<VirtualHost *:80>
  ServerName any
  DocumentRoot "/var/www/html/default_80"
</VirtualHost>
---

postfixadmin用の設定(https)

vi /etc/httpd/conf.d/postfixadmin.conf
---
<VirtualHost *:443>
  ServerName admin.xxx.com
  DocumentRoot /var/www/html/postfixadmin

  SSLEngine on

  SSLCertificateFile /etc/pki/tls/certs/localhost.crt
  SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
</VirtualHost>
---

Apacheの再起動

systemctl restart httpd

SSL証明書発行(Let's Encrypt)

以下を参照
https://qiita.com/T_Tsan/items/df2646aa1eddaa359fa9

certbot certonly --webroot -w /var/www/html/default_80 -m (管理者メールアドレス) -d (SSLを発行したいドメイン)-n --agree-tos

今回使う予定のドメインは、すべて発行してください。

Apache SSL証明書設定

Let's Encrypt発行した証明書と入れ替える。

vi /etc/httpd/conf.d/postfixadmin.conf
---
  SSLCertificateFile /etc/pki/tls/certs/localhost.crt
  SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
 ↓
  SSLCertificateFile /etc/letsencrypt/live/admin.xxx.com/fullchain.pem
  SSLCertificateKeyFile /etc/letsencrypt/live/admin.xxx.com/privkey.pem
---

Apacheの再起動

systemctl restart httpd

postfixadminの設定

cd /srv/
wget -O postfixadmin.tgz https://github.com/postfixadmin/postfixadmin/archive/postfixadmin-3.3.15.tar.gz
tar -zxvf postfixadmin.tgz
mv postfixadmin-postfixadmin-3.3.15 postfixadmin
ln -s /srv/postfixadmin/public /var/www/html/postfixadmin

# Sqlite
mkdir /srv/postfixadmin/database
touch /srv/postfixadmin/database/postfixadmin.db
chown -R apache:apache /srv/postfixadmin/database

# templates_c作成
mkdir -p /srv/postfixadmin/templates_c
chown -R apache:apache /srv/postfixadmin/templates_c

confファイル作成(最低限)
(必要に応じて設定を追加してください。)

vi /srv/postfixadmin/config.local.php
---
<?php
$CONF['database_type'] = 'sqlite';
$CONF['database_name'] = '/srv/postfixadmin/database/postfixadmin.db';

$CONF['configured'] = true;
?>
---

セットアップ
https://admin.xxx.com/setup.php
へアクセス

  • Generate setup_passwordへ任意のパスワードを入力 ←これは忘れないように・・・
  • $CONF['setup_password'] = 'xxxxx・・・'; が表示されるのでこれをメモ
  • confファイルへメモした設定を記述
vi /srv/postfixadmin/config.local.php
---
$CONF['configured'] = true;
↓
$CONF['configured'] = true;
$CONF['setup_password'] = 'xxxxx・・・'; 
?>
---

設定が終わったら、ブラウザをリロードする。
https://admin.xxx.com/setup.php)
「Setup password」には、先に設定した「Generate setup_password」を入力して、管理者を追加してください。
postfix_admin-1.png

管理者の追加が終わったら、ログイン画面へ移動する。
https://admin.xxx.com/login.php

次回は、Postfix/Dovecotの設定をおこないます。

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?