サーバー設定 · 2 min read · Dec 04, 2025
完璧なサーバー - Mandriva 2009.0 Free (i386) - ページ 5
10 MySQL (5.0)
MySQL 5.0をインストールするには、単に次のコマンドを実行します:
urpmi MySQL MySQL-client libmysql15-develデフォルトでは、Mandriva 2009.0の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 3181/mysqlmanager
tcp 0 0 *:mysql *:* LISTEN 3190/mysqld
[root@server1 var]#次に、次のコマンドを実行します
mysqladmin -u root password yourrootsqlpassword
mysqladmin -h server1.example.com -u root password yourrootsqlpasswordrootユーザーのパスワードを設定します(そうしないと誰でもあなたのMySQLデータベースにアクセスできます!)。
11 Postfix With SMTP-AUTH And TLS; Dovecot
必要なパッケージ(Postfix、cyrus-sasl、Dovecotなど)を次のようにインストールします:
urpmi cyrus-sasl libsasl2 libsasl2-devel libsasl2-plug-plain libsasl2-plug-anonymous libsasl2-plug-crammd5 libsasl2-plug-digestmd5 libsasl2-plug-gssapi libsasl2-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 |
saslauthdのデフォルトの認証メカニズムはpamですが、Mandriva 2009.0にはバグがあるようです。メールを送信すると、最初の1通は通過しますが、2通目を送信しようとするとsaslauthdが死んでしまいます。/var/log/messagesに次のようなメッセージが表示されます:
Oct 9 17:53:42 server1 saslauthd[4460]: server_exit : master exited: 4460次の回避策を見つけました:/etc/sysconfig/saslauthdを開きます…
vi /etc/sysconfig/saslauthd… そしてSASL_AUTHMECHをpamからshadowに変更します:
| # $Id: saslauthd.sysconfig,v 1.1 2001/05/02 10:55:48 wiget Exp $ # 認証メカニズム(リストはsaslauthd -vを参照) SASL_AUTHMECH=shadow # リモートIMAPサーバーのホスト名(rimap認証メカニズムが使用される場合) # ldap認証メカニズムが使用される場合のldap設定ファイル SASL_MECH_OPTIONS= # 追加オプション(リストはsaslauthd -hを参照) SASLAUTHD_OPTS= |
TLSに必要なSSL証明書を作成します:
mkdir /etc/postfix/ssl
cd /etc/postfix/ssl/
openssl genrsa -des3 -rand /etc/hosts -out smtpd.key 1024chmod 600 smtpd.key
openssl req -new -key smtpd.key -out smtpd.csropenssl x509 -req -days 3650 -in smtpd.csr -signkey smtpd.key -out smtpd.crtopenssl rsa -in smtpd.key -out smtpd.key.unencryptedmv -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| [...] # 提供したいプロトコル: imap imaps pop3 pop3s # dovecot-authのみを使用したい場合は、これを"none"に設定できます。 protocols = imap imaps pop3 pop3s [...] disable_plaintext_auth = no [...] pop3_uidl_format = %08Xu%08Xv [...] |
次に、Dovecotがntpdが起動した後にのみ起動するようにシステムに指示する必要があります。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
mv S54dovecot S99dovecot
cd /etc/rc4.d
mv S99ntpd S98ntpd
mv S54dovecot S99dovecot
cd /etc/rc5.d
mv S99ntpd S98ntpd
mv S54dovecot S99dovecot次に、Postfixのシステム起動リンクを作成します…
chkconfig postfix on… そして(再)起動します:
/etc/init.d/postfix restart
/etc/init.d/saslauthd restart
/etc/init.d/dovecot restartSMTP-AUTHとTLSが正しく機能するか確認するために、次のコマンドを実行します:
telnet localhost 25Postfixメールサーバーへの接続が確立されたら、次のように入力します
ehlo localhost次の行が表示される場合:
250-STARTTLSおよび
250-AUTH PLAIN LOGINすべてが正常です:
[root@server1 rc5.d]# 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.5) (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 rc5.d]#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新しい投稿を受信箱で受け取る
スパムはありません。いつでも購読を解除できます。