サーバー設定 · 2 min read · Oct 03, 2025

完璧なサーバー - Mandriva 2009.1 Free (x86_64) [ISPConfig 2] - ページ 5

10 MySQL 5

MySQL 5をインストールするには、単に次のコマンドを実行します:

urpmi MySQL MySQL-client lib64mysql-devel

デフォルトでは、Mandriva 2009.1のMySQLパッケージではネットワーキングが有効になっていませんが、ISPConfigにはネットワーキングが必要です。この設定は、/etc/my.cnfのskip-networking行をコメントアウトすることで変更できます。

vi /etc/my.cnf

| [...] # TCP/IPポートで全くリッスンしない。これはセキュリティの強化になる可能性があります。 # mysqldに接続する必要があるすべてのプロセスが同じホストで実行される場合。 # mysqldとのすべてのやり取りはUnixソケットまたは名前付きパイプを介して行う必要があります。 # このオプションを使用しても、Windowsで名前付きパイプを有効にしないと # ("enable-named-pipe"オプションを介して) mysqldは無用になります! # #skip-networking [...] |

その後、MySQLのシステム起動リンクを作成します…

chkconfig mysqld on

… そして起動します:

/etc/init.d/mysqld start

ネットワーキングが有効になっているか確認します。次のコマンドを実行します:

netstat -tap | grep mysql

出力は次のようになります:

[root@server1 var]# netstat -tap | grep mysql  
tcp        0      0 *:mysql-im                     *:*                     LISTEN      3411/mysqlmanager  
tcp        0      0 *:mysql                         *:*                     LISTEN      3421/mysqld  
[root@server1 var]#

次に、次のコマンドを実行します:

mysqladmin -u root password yourrootsqlpassword  
mysqladmin -h server1.example.com -u root password yourrootsqlpassword

rootユーザーのパスワードを設定します(そうしないと誰でもあなたのMySQLデータベースにアクセスできます!)。

11 Postfix With SMTP-AUTH And TLS; Dovecot

必要なパッケージ(Postfix、cyrus-sasl、Dovecotなど)を次のようにインストールします:

urpmi cyrus-sasl lib64sasl2 lib64sasl2-devel lib64sasl2-plug-plain lib64sasl2-plug-anonymous lib64sasl2-plug-crammd5 lib64sasl2-plug-digestmd5 lib64sasl2-plug-gssapi lib64sasl2-plug-login postfix dovecot

次に、次のコマンドを実行します:

postconf -e 'mydestination = /etc/postfix/local-host-names, localhost.$mydomain'  
postconf -e 'smtpd_sasl_local_domain ='  
postconf -e 'smtpd_sasl_auth_enable = yes'  
postconf -e 'smtpd_sasl_security_options = noanonymous'  
postconf -e 'broken_sasl_auth_clients = yes'  
postconf -e 'smtpd_sasl_authenticated_header = yes'  
postconf -e 'smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination'  
postconf -e 'inet_interfaces = all'  
postconf -e 'mynetworks = 127.0.0.0/8'  
touch /etc/postfix/local-host-names

次に、Postfixインストールのホスト名を設定します(server1とexample.comを自分の設定に置き換えてください):

postconf -e 'mydomain = example.com'  
postconf -e 'myhostname = server1.$mydomain'

/etc/sasl2/smtpd.confを編集します。次のようになります:

vi /etc/sasl2/smtpd.conf

| # postfix用のSASLライブラリ設定ファイル # すべてのパラメータは次のドキュメントに記載されています: # /usr/share/doc/cyrus-sasl/options.html # mech_listパラメータは使用するsaslメカニズムをリストします。 # デフォルトは見つかったすべてのメカニズムです。 mech_list: plain login # 別のsaslauthdデーモンを使用して認証するために(例: # システムまたはldapユーザー)。/etc/sysconfig/saslauthdも参照してください。 pwcheck_method: saslauthd saslauthd_path: /var/lib/sasl2/mux # sasldbに保存されたユーザーに対して認証します。 #pwcheck_method: auxprop #auxprop_plugin: sasldb #sasldb_path: /var/lib/sasl2/sasl.db |

TLSに必要なSSL証明書を作成します:

mkdir /etc/postfix/ssl  
cd /etc/postfix/ssl/  
openssl genrsa -des3 -rand /etc/hosts -out smtpd.key 1024
chmod 600 smtpd.key  
openssl req -new -key smtpd.key -out smtpd.csr
openssl x509 -req -days 3650 -in smtpd.csr -signkey smtpd.key -out smtpd.crt
openssl rsa -in smtpd.key -out smtpd.key.unencrypted
mv -f smtpd.key.unencrypted smtpd.key  
openssl req -new -x509 -extensions v3_ca -keyout cakey.pem -out cacert.pem -days 3650

… そしてPostfixをTLS用に設定します:

postconf -e 'smtpd_tls_auth_only = no'  
postconf -e 'smtp_use_tls = yes'  
postconf -e 'smtpd_use_tls = yes'  
postconf -e 'smtp_tls_note_starttls_offer = yes'  
postconf -e 'smtpd_tls_key_file = /etc/postfix/ssl/smtpd.key'  
postconf -e 'smtpd_tls_cert_file = /etc/postfix/ssl/smtpd.crt'  
postconf -e 'smtpd_tls_CAfile = /etc/postfix/ssl/cacert.pem'  
postconf -e 'smtpd_tls_loglevel = 1'  
postconf -e 'smtpd_tls_received_header = yes'  
postconf -e 'smtpd_tls_session_cache_timeout = 3600s'  
postconf -e 'tls_random_source = dev:/dev/urandom'

次に、Dovecotを設定してimap、imaps、pop3、pop3sのプロトコルを提供します。/etc/dovecot.confを開き、次の値を調整します:

vi /etc/dovecot.conf

| [...] protocols = imap imaps pop3 pop3s [...] disable_plaintext_auth = no [...] pop3_uidl_format = %08Xu%08Xv [...] |

次に、ntpdが起動した後にのみDovecotを起動するようにシステムに指示する必要があります。Dovecotが実行中にシステムの時間が逆行すると、Dovecotはあまり寛容ではありません(http://wiki.dovecot.org/TimeMovedBackwardsを参照)。これにより、syslogに次のようなエラーが発生する可能性があります:

Apr  9 19:29:18 server1 dovecot: 時間が17秒戻りました。これにより多くの問題が発生する可能性があるため、私は今すぐ自分を殺します。http://wiki.dovecot.org/TimeMovedBackwards

残念ながら、MandrivaではDovecotはntpdの前に起動するため、次のように変更します:

cd /etc/rc3.d  
mv S99ntpd S98ntpd  
cd /etc/rc4.d  
mv S99ntpd S98ntpd  
cd /etc/rc5.d  
mv S99ntpd S98ntpd

次に、Postfixのシステム起動リンクを作成します…

chkconfig postfix on

… そして(再)起動します、Postfix、saslauthd、およびDovecot:

/etc/init.d/postfix restart  
/etc/init.d/saslauthd restart  
/etc/init.d/dovecot restart

SMTP-AUTHとTLSが正常に動作しているか確認するには、次のコマンドを実行します:

telnet localhost 25

Postfixメールサーバーへの接続が確立された後、次のコマンドを入力します:

ehlo localhost

次の行が表示される場合:

250-STARTTLS

および

250-AUTH PLAIN LOGIN

すべてが正常です:

[root@server1 ssl]# telnet localhost 25  
Trying 127.0.0.1...  
Connected to localhost.localdomain (127.0.0.1).  
Escape character is '^]'.  
220 server1.example.com ESMTP Postfix (2.5.6) (Mandriva Linux)  
ehlo localhost  
250-server1.example.com  
250-PIPELINING  
250-SIZE 10240000  
250-VRFY  
250-ETRN  
250-STARTTLS  
250-AUTH PLAIN LOGIN  
250-AUTH=PLAIN LOGIN  
250-ENHANCEDSTATUSCODES  
250-8BITMIME  
250 DSN  
quit  
221 2.0.0 Bye  
Connection closed by foreign host.  
[root@server1 ssl]#
quit

と入力してシステムのシェルに戻ります。

11.1 Maildir

DovecotはMaildir形式(mboxではない)を使用しているため、サーバーにISPConfigをインストールする場合は、Management -> Server -> Settings -> EmailでMaildirを有効にすることを確認してください。ISPConfigは必要な設定を行います。

ISPConfigをインストールしたくない場合は、PostfixをユーザーのMaildirにメールを配信するように設定する必要があります(ISPConfigを使用している場合でもこれを行うことができます - 害はありません;):

postconf -e 'home_mailbox = Maildir/'  
postconf -e 'mailbox_command ='  
/etc/init.d/postfix restart
Share: X/Twitter LinkedIn

新しい投稿を受信箱で受け取る

スパムはありません。いつでも購読を解除できます。