これまでメールサーバは主に qmail で運用してきましたが、インストールするたびにパッチの検証をするのも面倒になってきたので、qmail + vpopmail + qmailadmin + dovecot といういつものパターンをやめて、Postfix + postfixadmin + MySQL + dovecot という構成に挑戦することにしました。
今日はまず MySQL + postfixadmin のインストール方法までをまとめておきます。
† まずは apache や php をインストール
postfixadmin を動かすために apache や php が必要になるのでインストールしておきます。
必要に応じて /etc/php.ini も変更しておきます。
yum groupinstall "Development Tools" -y
yum groupinstall "Web Server" -y
yum -y install php php-mbstring php-pear php-mysql php-cli php-common php-pecl-apc
diff -u php.ini.org php.ini
--- php.ini.org 2013-12-11 12:34:42.000000000 +0900
+++ php.ini 2014-05-26 16:54:48.362263368 +0900
@@ -943,7 +943,7 @@
[Date]
; Defines the default timezone used by the date functions
; http://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone
-;date.timezone =
+date.timezone = Asia/Tokyo
; http://www.php.net/manual/en/datetime.configuration.php#ini.date.default-latitude
;date.default_latitude = 31.7667
@@ -1545,7 +1545,7 @@
; Some encoding cannot work as internal encoding.
; (e.g. SJIS, BIG5, ISO-2022-*)
; http://www.php.net/manual/en/mbstring.configuration.php#ini.mbstring.internal-encoding
-;mbstring.internal_encoding = EUC-JP
+mbstring.internal_encoding = UTF-8
; http input encoding.
; http://www.php.net/manual/en/mbstring.configuration.php#ini.mbstring.http-input
† postfix から使うデータベースの作成
必要なテーブルは postfixadmin のセットアップ時に作成されるので、ユーザーとデータベースだけを作成しておきます。
ユーザーのパスワードは ###MYSQL_PASSWORD### と書いてありますが、実際のパスワードに読み替えてください。
$ mysql -u root -p
mysql> CREATE DATABASE postfix;
mysql> CREATE USER 'postfix'@'localhost' IDENTIFIED BY '###MYSQL_PASSWORD###';
mysql> GRANT ALL PRIVILEGES ON `postfix` . * TO 'postfix'@'localhost';
† postfixadmin のインストール
postfixadmin をインストールする準備が整ったので、postfixadmin をインストールします。
php で書かれたプログラムなので、インストールといってもファイルを配置するだけです。
† postfixadmin の設定
まずは設定ファイルを以下のように書き換えます。
cd /var/www
wget "http://downloads.sourceforge.net/project/postfixadmin/postfixadmin/postfixadmin-2.91/postfixadmin-2.91.tar.gz"
tar zxvf postfixadmin-2.91.tar.gz
ln -s postfixadmin-2.91 postfixadmin
ファイルが配置できたら、設定ファイル (config.inc.php) を書き換えます。
1カ所 XXXXXXXXXXX・・・ という部分がありますが、ここの内容は次のステップの初期設定中に表示される指示に従ってください。
/var/www/postfixadmin/config.inc.php
--- config.inc.php.org 2013-12-26 23:35:02.000000000 +0900
+++ config.inc.php 2014-05-26 17:03:37.772262746 +0900
@@ -22,16 +22,16 @@
* 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;
// 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,
// on submission it will be echoed out to you as a hashed value.
-$CONF['setup_password'] = 'changeme';
+$CONF['setup_password'] = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
// Language config
// Language files are located in './languages', change as required..
-$CONF['default_language'] = 'en';
+$CONF['default_language'] = 'ja';
// Hook to override or add translations in $PALANG
// Set to the function name you want to use as hook function (see language_hook example function below)
@@ -83,7 +83,7 @@
$CONF['database_type'] = 'mysqli';
$CONF['database_host'] = 'localhost';
$CONF['database_user'] = 'postfix';
-$CONF['database_password'] = 'postfixadmin';
+$CONF['database_password'] = '###MYSQL_PASSWORD###';
$CONF['database_name'] = 'postfix';
// If you need to specify a different port for a MYSQL database connection, use e.g.
// $CONF['database_host'] = '172.30.33.66:3308';
@@ -132,7 +132,8 @@
// authlib = support for courier-authlib style passwords
// dovecot:CRYPT-METHOD = use dovecotpw -s 'CRYPT-METHOD'. Example: dovecot:CRAM-MD5
// (WARNING: don't use dovecot:* methods that include the username in the hash - you won't be able to login to PostfixAdmin in this case)
-$CONF['encrypt'] = 'md5crypt';
+//$CONF['encrypt'] = 'md5crypt';
+$CONF['encrypt'] = 'cleartext';
// In what flavor should courier-authlib style passwords be encrypted?
// md5 = {md5} + base64 encoded md5 hash
@@ -176,7 +177,7 @@
// Page Size
// Set the number of entries that you would like to see
// in one page.
-$CONF['page_size'] = '10';
+$CONF['page_size'] = '100';
// Default Aliases
// The default aliases that need to be created for all domains.
@@ -272,16 +273,16 @@
// Default Domain Values
// Specify your default values below. Quota in MB.
-$CONF['aliases'] = '10';
-$CONF['mailboxes'] = '10';
-$CONF['maxquota'] = '10';
+$CONF['aliases'] = '1000';
+$CONF['mailboxes'] = '1000';
+$CONF['maxquota'] = '10000';
$CONF['domain_quota_default'] = '2048';
// Quota
// When you want to enforce quota for your mailbox users set this to 'YES'.
$CONF['quota'] = 'NO';
// If you want to enforce domain-level quotas set this to 'YES'.
-$CONF['domain_quota'] = 'YES';
+$CONF['domain_quota'] = 'NO';
// You can either use '1024000' or '1048576'
$CONF['quota_multiplier'] = '1024000';
@@ -385,7 +386,7 @@
// Send Mail
// If you don't want sendmail tab set this to 'NO';
-$CONF['sendmail'] = 'YES';
+$CONF['sendmail'] = 'NO';
// Logging
// If you don't want logging set this to 'NO';
@@ -393,7 +394,7 @@
// Fetchmail
// If you don't want fetchmail tab set this to 'NO';
-$CONF['fetchmail'] = 'YES';
+$CONF['fetchmail'] = 'NO';
// fetchmail_extra_options allows users to specify any fetchmail options and any MDA
// (it will even accept 'rm -rf /' as MDA!)
@@ -408,8 +409,8 @@
// 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'] = 'Postfix Admin Top';
+$CONF['footer_link'] = '/postfixadmin/';
// MOTD ("Motto of the day")
// You can display a MOTD below the menu on all pages.
@@ -429,7 +430,7 @@
// When creating mailboxes or aliases, check that the domain-part of the
// address is legal by performing a name server look-up.
-$CONF['emailcheck_resolve_domain']='YES';
+$CONF['emailcheck_resolve_domain']='NO';
// Optional:
今回は /var/www 以下にファイルを配置していないので、下記のように設定を追加して /postfixadmin で表示されるようにしてやります。
/etc/httpd/conf.d/postfixadmin.conf
Alias /postfixadmin "/var/www/postfixadmin"
<Directory "/var/www/postfixadmin">
Order allow,deny
Allow from all
</Directory>
最後にサービスをリスタートすればインストールは完了 OK。
/etc/init.d/http restart
† 初期設定
ブラウザで初期設定 http://server.example.com/postfixadmin/setup.php を開いて画面の指示に従います。
完了したら setup.php は不要なのでサーバから削除しておきます。
今日はここまで。その2に続きます。
† 参考情報