postfixadmin の初期設定と起動確認

マージしたら postfixadmin を準備する。 SMTP でメールを送ろうにも、アカウントを DB 上に登録する作業が必要なので、最初に最初にコレをやれば postfixadmin の機能を使ってアカウント増やしたりできて楽である。また、管理者権限でメールを送信したりすることもできる。

データベースの名称やアクセスアカウントを考える

まず MySQL で作成するメールアカウント管理用 DB 名と認証用アカウント名を考えておく。

DB 名 postfix
アカウント名 パスワード
更新専用 postfixadmin adminpass
参照専用 postfix authpass


今回は上記のように取り決める。もちろん実際のパスワードはちゃんと考えること。

webapp-config を用いた postfixadmin の配置

Gentoo で vhosts オプションをつけてインストールした場合こんな感じで配置できる。

$ sudo webapp-config -I -h localhost -d postfixadmin postfixadmin 2.3.2
 とか
$ sudo webapp-config -I -h mailadmin.kakitsubata-ayame.net postfixadmin 2.3.2
 とか


今回は localhost に postfixadmin ディレクトリをつけて配置... http://localhost/postfixadmin/ になるようにインストールしているので、必要に応じて各自読み替えること。

$ sudo webapp-config -I -h localhost -d postfixadmin postfixadmin 2.3.2
*   Creating required directories
*   Linking in required files
*     This can take several minutes for larger apps
*   Files and directories installed

=================================================================
POST-INSTALL INSTRUCTIONS
=================================================================

You will need to provide a database for your postfixadmin installation.

This assumes you have some knowledge of MySQL, and already have it
installed and configured. If not, please refer to the Gentoo MySQL
guide at the following URL:

http://www.gentoo.org/doc/en/mysql-howto.xml

Log in to MySQL, and create a new database as well as a user with full
access to this database. After that you will need to provide the details
of this database and the associated user within the file

/var/www/localhost/htdocs/postfixadmin/config.inc.php

Make sure you also set

  ['configured'] = true;

in this file.

Finally you should be able to complete the installation of postfixadmin
by pointing your browser at

  http://localhost/postfixadmin/setup.php


Updating from older version of Postfix Admin:
  * When you are upgrading from an older Postfix Admin version, make sure you
  * backup your database before you run the update script on your database.
  *   mysqldump -a -u root -p > /tmp/postfixadmin-backup.sql

  For update from version 1.5.x of Postfix Admin:
    1. Please read the DOCUMENTS/UPGRADE.TXT
        2. Run: http://localhost/postfixadmin/setup.php


To use Virtual Vacation, please read VIRTUAL_VACATION_INSTALL.

Check the config.inc.php file. There you can specify settings that are
relevant to your setup.

Postfix Admin contains 3 views of administration:
  1. Site Admin view, located at http://localhost/postfixadmin/admin/.
  2. Domain Admin view, located at http://localhost/postfixadmin/.
  3. User Admin View, located at http://localhost/postfixadmin/users/.

In order to do the initial configuration you have to go to the Site Admin view.

=================================================================

* Install completed - success
オプションについて
-I はインストール。 -h がインストールする apache の vhost 。 -d が htdocs 以下のディレクトリ。最後のはアプリ名とバージョン。 (ちなみに、間違えてインストールしてしまった場合等々で消したい場合は -I を -C にするだけ。)


次にインストールしたディレクトリに行って必要なファイルを書き換える。

コンフィグファイルの書き換え

インストールログにあるとおり config.inc.php の書き換えから始める。基本的には MySQL へアクセスする部分と設定完了の部分、それからディレクトリ形式を決めるところ以外はドメイン名称等を自分の環境に合わせてひたすら置換していくだけである。

--- config.inc.php.orig	2011-03-29 04:26:27.144433743 +0900
+++ config.inc.php	2011-03-29 04:46:35.163536098 +0900
@@ -23,7 +23,7 @@
  * Doing this implies you have changed this file as required.
  * i.e. configuring database etc; specifying setup.php password etc.
  */
-$CONF['configured'] = false;
+$CONF['configured'] = true;                          ここを true にすると設定完了扱い
 
 // In order to setup Postfixadmin, you MUST specify a hashed password here.
 // To create the hash, visit setup.php in a browser and type a password into the field,
@@ -40,7 +40,7 @@
 
 // Language config
 // Language files are located in './languages', change as required..
-$CONF['default_language'] = 'en';
+$CONF['default_language'] = 'ja';                    日本語表示にしたければ ja で
 
 // Database Config
 // mysql = MySQL 3.23 and 4.0, 4.1 or 5
@@ -48,8 +48,8 @@
 // pgsql = PostgreSQL
 $CONF['database_type'] = 'mysql';                    ここからDB更新用の設定
 $CONF['database_host'] = 'localhost';                    DBのあるホスト
-$CONF['database_user'] = 'postfix';
-$CONF['database_password'] = 'postfixadmin';
+$CONF['database_user'] = 'postfixadmin';                 DB更新用ユーザ名
+$CONF['database_password'] = 'adminpass';                上記のパス
 $CONF['database_name'] = 'postfix';                      DB名
 $CONF['database_prefix'] = '';
 // If you need to specify a different port for a MYSQL database connection, use e.g.
@@ -80,7 +80,7 @@
 // Site Admin
 // Define the Site Admins email address below.
 // This will be used to send emails from to create mailboxes.
-$CONF['admin_email'] = 'postmaster@change-this-to-your.domain.tld';
+$CONF['admin_email'] = 'postmaster@niboshi.kakitsubata-ayame.net';
 
 // Mail Server
 // Hostname (FQDN) of your mail server.
@@ -131,10 +131,10 @@
 // Default Aliases
 // The default aliases that need to be created for all domains.
 $CONF['default_aliases'] = array (
-    'abuse' => 'abuse@change-this-to-your.domain.tld',
-    'hostmaster' => 'hostmaster@change-this-to-your.domain.tld',
-    'postmaster' => 'postmaster@change-this-to-your.domain.tld',
-    'webmaster' => 'webmaster@change-this-to-your.domain.tld'
+    'abuse' => 'abuse@niboshi.kakitsubata-ayame.net',
+    'hostmaster' => 'hostmaster@niboshi.kakitsubata-ayame.net',
+    'postmaster' => 'postmaster@niboshi.kakitsubata-ayame.net',
+    'webmaster' => 'webmaster@niboshi.kakitsubata-ayame.net'
 );
 
 // Mailboxes
@@ -142,13 +142,13 @@
 // Examples:
 //   YES: /usr/local/virtual/domain.tld/username@domain.tld
 //   NO:  /usr/local/virtual/username@domain.tld
-$CONF['domain_path'] = 'NO';
+$CONF['domain_path'] = 'YES';                            実メール管理ディレクトリの形式指定
                                                          今回は /var/vmail/%domain%/%user% を想定するので YES で
 // If you don't want to have the domain in your mailbox set this to 'NO'.
 // Examples: 
 //   YES: /usr/local/virtual/domain.tld/username@domain.tld
 //   NO:  /usr/local/virtual/domain.tld/username
 // Note: If $CONF['domain_path'] is set to NO, this setting will be forced to YES.
-$CONF['domain_in_mailbox'] = 'YES';
+$CONF['domain_in_mailbox'] = 'NO';                       上に同様
 // If you want to define your own function to generate a maildir path set this to the name of the function.
 // Notes: 
 //   - this configuration directive will override both domain_path and domain_in_mailbox
@@ -214,7 +214,7 @@
 // This is the autoreply domain that you will need to set in your Postfix
 // transport maps to handle virtual vacations. It does not need to be a
 // real domain (i.e. you don't need to setup DNS for it).
-$CONF['vacation_domain'] = 'autoreply.change-this-to-your.domain.tld';
+$CONF['vacation_domain'] = 'autoreply.niboshi.kakitsubata-ayame.net';
 
 // Vacation Control
 // If you want users to take control of vacation set this to 'YES'.
@@ -279,14 +279,14 @@
 $CONF['header_text'] = ':: Postfix Admin ::';
 
 // link to display under 'Main' menu when logged in as a user.
-$CONF['user_footer_link'] = "http://change-this-to-your.domain.tld/main";
+$CONF['user_footer_link'] = "https://niboshi.kakitsubata-ayame.net/postfixadmin/main";
 
 // Footer
 // Below information will be on all pages.
 // If you don't want the footer information to appear set this to 'NO'.
 $CONF['show_footer_text'] = 'YES';
-$CONF['footer_text'] = 'Return to change-this-to-your.domain.tld';
-$CONF['footer_link'] = 'http://change-this-to-your.domain.tld';
+$CONF['footer_text'] = 'Return to top page';
+$CONF['footer_link'] = 'https://niboshi.kakitsubata-ayame.net/postfixadmin';
 
 // Welcome Message
 // This message is send to every newly created mailbox.

アクセスしてみる

ここまで行ったら ./setup.php にアクセスしてみる。


postfixadmin/setup.php 初回アクセス画面


エラーが出ているが MySQL に接続できないよというエラーである。設定していないのだから当然である。

データベースを作る

ここで MySQL に入ってデータベース、及びデータベース更新/参照用ユーザを作成する。

$ mysql -u root -p

mysql> CREATE DATABASE postfix;
Query OK, 1 row affected (0.00 sec)

mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,ALTER,INDEX on postfix.* 
mysql> to 'postfixadmin'@'localhost' IDENTIFIED by 'adminpass';
Query OK, 0 rows affected (0.36 sec)

mysql> GRANT SELECT on postfix.* to 'postfix'@'localhost' IDENTIFIED by 'authpass';
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

再度アクセスして設定を完了する

再度先程の ./setup.php にアクセスしてみる。パスワード等が正しく設定されていれば通るはずである。ところどころエラーが出ているかもしれないがあまり気にしなくていいはず。


DB 設定後の再アクセス


そこまで行ったら管理者用のパスワードを打ち込む


管理者用パスワード設定…ぼかしてある


次にコンソールに戻り、得られた暗号化されたパスワードを config.inc.php の $CONF['setup_password'] = 'changeme'; のところに打ちこんで再度アクセスする…と、その管理者パスワードさえあれば正式な管理者 ID を発行できるようになるので、そのパスワードを使って管理者 ID を追加する。

そこまで終わったら setup.php は不要であるので、削除すること。これ以降アカウントの管理は先程作った管理者 ID を使う。

試しに入ってみる

設定が完了したら試しにログインしてみる。


postfixadmin ログイン画面



postfixadmin 管理画面


まだ MTA の設定をしていないのでメール送信テスト等は行えない。ローカル (niboshi.kakitsubata-ayame.net) のドメインだけつくっておくと良い。そこまで終わったら引き続き postfix の初期設定を行ってゆく。