インストールガイド · 2 min read · Feb 03, 2026
Debian Sarge (3.1) with Ruby on Rails and Apache 2 with FastCGI - Page 3
MySQLのインストール
apt-get install mysql-server mysql-client libmysqlclient12-devmysqlのrootパスワードを設定します
mysqladmin -u root password yourrootsqlpassword
mysqladmin -h server1.example.com -u root password yourrootsqlpasswordnetstat -tapを実行すると、次のような行が表示されるはずです:
| tcp 0 0 localhost.localdo:mysql *:* |
これは、MySQLが127.0.0.1のポート3306でアクセス可能であることを意味します。次のセクション(Postfix)に進むことができます。この行が表示されない場合は、/etc/mysql/my.cnfを編集し、skip-networkingをコメントアウトします:
| # skip-networking |
MySQLがすべての利用可能なIPアドレスでリッスンするようにするには、/etc/mysql/my.cnfを編集し、bind-address = 127.0.0.1をコメントアウトします:
| # bind-address = 127.0.0.1 |
/etc/mysql/my.cnfを編集した場合は、MySQLを再起動する必要があります:
/etc/init.d/mysql restartPostfix/POP3/IMAPのインストール
SMTP-AUTHとTLSを使用したPostfixおよびPOP3サーバー(POP3s(ポート995)も対応)およびIMAPサーバー(IMAPs(ポート993)も対応)をインストールするには、次の手順を実行します:
apt-get install postfix postfix-tls libsasl2 sasl2-bin libsasl2-modules ipopd-ssl uw-imapd-sslプロンプトには次のように答えます:
libc-clientをMaildirサポートなしでインストールを続けますか?答え:いいえ
サーバーがリッスンするポートはどれですか?答え:pop3およびpop3s
ポート選択を強制しますか?答え:いいえ
サーバーがリッスンするポートはどれですか?答え:imap2およびimaps
ポート選択を強制しますか?答え:いいえ
構成の一般的なタイプは?答え:インターネットサイト
rootのメールはどこに送信されますか?答え:NONE
メール名は?答え:server1.example.com
他に受け入れるメールの宛先は?(なしの場合は空白)答え:server1.example.com, localhost.example.com, localhost
メールキューの同期更新を強制しますか?答え:いいえ
次に、Postfixを構成します:
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_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination'
postconf -e 'inet_interfaces = all'
echo 'pwcheck_method: saslauthd' >> /etc/postfix/sasl/smtpd.conf
echo 'mech_list: plain login' >> /etc/postfix/sasl/smtpd.confSSLを設定します
mkdir /etc/postfix/ssl
cd /etc/postfix/ssl/
openssl genrsa -des3 -rand /etc/hosts -out smtpd.key 1024smtpd.keyのために4から8191文字のパスフレーズを入力する必要があります
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以前に入力したsmtpd.keyのパスフレーズを入力する必要があります
openssl rsa -in smtpd.key -out smtpd.key.unencrypted以前に入力したsmtpd.keyのパスフレーズを入力する必要があります
mv -f smtpd.key.unencrypted smtpd.keyopenssl req -new -x509 -extensions v3_ca -keyout cakey.pem -out cacert.pem -days 3650証明書要求を入力するか、デフォルトを使用します
さらにPostfixの設定を行います
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'ファイル/etc/postfix/main.cfは次のようになります:
joe /etc/postfix/main.cf| # See /usr/share/postfix/main.cf.dist for a commented, more complete version smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU) biff = no # appending .domain is the MUA's job. append_dot_mydomain = no # Uncomment the next line to generate "delayed mail" warnings #delay_warning_time = 4h myhostname = server1.example.com alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases myorigin = /etc/mailname mydestination = server1.example.com, localhost.example.com, localhost relayhost = mynetworks = 127.0.0.0/8 mailbox_command = procmail -a "$EXTENSION" mailbox_size_limit = 0 recipient_delimiter = + inet_interfaces = all smtpd_sasl_local_domain = smtpd_sasl_auth_enable = yes smtpd_sasl_security_options = noanonymous broken_sasl_auth_clients = yes smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination smtpd_tls_auth_only = no smtp_use_tls = yes smtpd_use_tls = yes smtp_tls_note_starttls_offer = yes smtpd_tls_key_file = /etc/postfix/ssl/smtpd.key smtpd_tls_cert_file = /etc/postfix/ssl/smtpd.crt smtpd_tls_CAfile = /etc/postfix/ssl/cacert.pem smtpd_tls_loglevel = 1 smtpd_tls_received_header = yes smtpd_tls_session_cache_timeout = 3600s tls_random_source = dev:/dev/urandom |
Postfixを再起動します
/etc/init.d/postfix restart認証はsaslauthdによって行われます。これを適切に機能させるためにいくつかの変更を行う必要があります。Postfixは/var/spool/postfixでchrootされているため、次のことを行う必要があります:
mkdir -p /var/spool/postfix/var/run/saslauthd次に、/etc/default/saslauthdを編集してsaslauthdを有効にします。START=yesの前の#を削除し、PARAMS=”-m /var/spool/postfix/var/run/saslauthd -r”の行を追加します:
joe /etc/default/saslauthd| # This needs to be uncommented before saslauthd will be run automatically START=yes PARAMS="-m /var/spool/postfix/var/run/saslauthd -r" # You must specify the authentication mechanisms you wish to use. # This defaults to "pam" for PAM support, but may also include # "shadow" or "sasldb", like this: # MECHANISMS="pam shadow" MECHANISMS="pam" |
次に、saslauthdを起動します:
/etc/init.d/saslauthd start次に、ファイル/etc/c-client.cfを作成します:
echo "I accept the risk" > /etc/c-client.cf echo "set disable-plaintext 0" >> /etc/c-client.cf次にinetdを再起動します:
/etc/init.d/inetd restartこれを行わないと、POP3/IMAPのログインが失敗します。
SMTP-AUTHとTLSが正しく機能するかどうかを確認するには、次のコマンドを実行します:
telnet localhost 25Postfixメールサーバーへの接続が確立されたら、次のように入力します
ehlo localhost次の行が表示される場合:
250-STARTTLSおよび
250-AUTHすべてが正常です。
quitと入力してシステムのシェルに戻ります。
Maildirサポートを持つCourier-IMAP/Courier-POP3のインストール
apt-get install courier-imap courier-imap-ssl courier-pop courier-pop-sslプロンプトには次のように答えます:
ウェブベースの管理用のディレクトリを作成しますか?答え:いいえ
SSL証明書が必要ですか?答え:OK
次に、Postfixを構成してユーザーのMaildirにメールを配信します:
postconf -e 'home_mailbox = Maildir/'
postconf -e 'mailbox_command ='
/etc/init.d/postfix restart新しい投稿を受信箱で受け取る
スパムはありません。いつでも購読を解除できます。