サーバー設定 · 2 min read · Sep 20, 2025
完璧なサーバー - OpenSUSE 11.3 x86_64 [ISPConfig 2] - ページ 4
8 MySQL
MySQLをインストールするために、次のコマンドを実行します。
yast2 -i mysql mysql-community-server mysql-client perl-DBD-mysql perl-DBI perl-Data-ShowTable libmysqlclient-devel libmysqlclient16 libmysqlclient16-32bit libmysqlclient_r16-32bit
次に、MySQLのシステム起動リンクを追加し、起動します。
chkconfig –add mysql
/etc/init.d/mysql start
ネットワークが有効になっていることを確認します。次のコマンドを実行します。
netstat -tap | grep mysql出力には次のような行が表示されるはずです。
server1:~ # netstat -tap | grep mysql
tcp 0 0 :mysql :* LISTEN 5336/mysqld
server1:~ #
この行が表示されない場合は、/etc/my.cnfを編集し、skip-networkingオプションをコメントアウトします。
vi /etc/my.cnf| [...] #skip-networking [...] |
MySQLサーバーを再起動します。
/etc/init.d/mysql restartMySQLインストールを保護するために、次のコマンドを実行します。
mysql_secure_installationいくつかの質問が表示されます。
server1:~ # mysql_secure_installation
NOTE: このスクリプトのすべての部分を実行することは、すべてのMySQLサーバーで推奨されます。 本番環境で使用する場合は、各ステップを注意深くお読みください!
MySQLにログインして保護するためには、rootユーザーの現在のパスワードが必要です。 MySQLをインストールしたばかりで、まだrootパスワードを設定していない場合、パスワードは空白になりますので、ここではEnterを押してください。
現在のrootのパスワードを入力してください(なしの場合はEnter): <– ENTER
OK、パスワードが正常に使用されました。次に進みます…
rootパスワードを設定することで、適切な認証なしに誰もMySQLのrootユーザーにログインできないようにします。
rootパスワードを設定しますか? [Y/n] <– ENTER
新しいパスワード: <– yourrootsqlpassword
新しいパスワードを再入力してください: <– yourrootsqlpassword
パスワードが正常に更新されました!
特権テーブルを再読み込みしています..
… 成功!
デフォルトでは、MySQLインストールには匿名ユーザーがあり、誰でもユーザーアカウントを作成せずにMySQLにログインできます。 これはテスト用にのみ意図されており、インストールを少しスムーズにするためのものです。 本番環境に移行する前に、これらを削除する必要があります。
匿名ユーザーを削除しますか? [Y/n] <– ENTER
… 成功!
通常、rootは「localhost」からのみ接続を許可されるべきです。 これにより、誰かがネットワークからrootパスワードを推測できないようになります。
リモートからのrootログインを禁止しますか? [Y/n] <– ENTER
… 成功!
デフォルトでは、MySQLには「test」という名前のデータベースがあり、誰でもアクセスできます。 これもテスト用にのみ意図されており、本番環境に移行する前に削除する必要があります。
テストデータベースとそのアクセスを削除しますか? [Y/n] <– ENTER
- テストデータベースを削除しています…
… 成功! - テストデータベースの特権を削除しています…
… 成功!
特権テーブルを再読み込みすることで、これまでに行ったすべての変更が即座に反映されることを保証します。
特権テーブルを今すぐ再読み込みしますか? [Y/n] <– ENTER
… 成功!
クリーンアップ中…
すべて完了しました! 上記のすべてのステップを完了した場合、MySQLインストールは今や安全であるはずです。
MySQLをご利用いただきありがとうございます!
server1:~ #
これでMySQLの設定は安全になりました。
次に、これを行う必要があります…
mkdir -p /usr/local/lib/mysql
ln -s /usr/include/mysql /usr/local/lib/mysql/include
ln -s /usr/lib64/mysql /usr/local/lib/mysql/lib
cd /usr/local/lib/mysql/lib
ln -s /usr/lib64/libmysqlclient.so.16.0.0 libmysqlclient.so
ln -s /usr/lib64/libmysqlclient.so.16.0.0 libmysqlclient.so.16
ln -s /usr/lib64/libmysqlclient.so.16.0.0 libmysqlclient.so.16.0.0
ln -s /usr/lib64/libmysqlclient_r.so.16.0.0 libmysqlclient_r.so
ln -s /usr/lib64/libmysqlclient_r.so.16.0.0 libmysqlclient_r.so.16
ln -s /usr/lib64/libmysqlclient_r.so.16.0.0 libmysqlclient_r.so.16.0.0
… さもなければ、ISPConfigのインストール中に次のエラーが発生します。
configure: error: Cannot find libmysqlclient under /usr/local/lib/mysql. 9 Postfix With SMTP-AUTH And TLS
次に、PostfixとCyrus-SASLをインストールします。
yast2 -i postfix cyrus-sasl cyrus-sasl-crammd5 cyrus-sasl-digestmd5 cyrus-sasl-gssapi cyrus-sasl-otp cyrus-sasl-plain cyrus-sasl-saslauthd procmail次に、Postfixとsaslauthdのシステム起動リンクを追加し、起動します。
chkconfig –add postfix
/etc/init.d/postfix start
chkconfig –add saslauthd
/etc/init.d/saslauthd start
その後、TLS用の証明書を作成します。
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.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
次に、SMTP-AUTHとTLSのためにPostfixを設定します。
postconf -e ‘mydomain = example.com’
postconf -e ‘myhostname = server1.$mydomain’
postconf -e ‘mynetworks = 127.0.0.0/8’
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,check_relay_domains’
postconf -e ‘inet_interfaces = all’
postconf -e ‘alias_maps = hash:/etc/aliases’
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’
(正しいホスト名/ドメインをmydomainとmyhostnameに使用していることを確認してください!)
PostfixでTLS接続を有効にするには、/etc/postfix/master.cfを編集し、tlsmgr行のコメントを外して次のようにします。
vi /etc/postfix/master.cf| [...] tlsmgr unix - - n 1000? 1 tlsmgr [...] |
Postfixを再起動します。
/etc/init.d/postfix restartSMTP-AUTHとTLSが正しく機能しているかを確認するには、次のコマンドを実行します。
telnet localhost 25Postfixメールサーバーへの接続が確立された後、次のように入力します。
ehlo localhost次の行が表示される場合、すべてが正常です。
250-STARTTLSおよび
250-AUTH LOGIN PLAIN 私のシステムでは、出力は次のようになります。
server1:/etc/postfix/ssl # telnet localhost 25
Trying ::1…
Connected to localhost.
Escape character is ‘^]’.
220 server1.example.com ESMTP Postfix
ehlo localhost
250-server1.example.com
250-PIPELINING
250-SIZE
250-VRFY
250-ETRN
250-STARTTLS
250-AUTH LOGIN PLAIN
250-AUTH=LOGIN PLAIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
quit
221 2.0.0 Bye
Connection closed by foreign host.
server1:/etc/postfix/ssl #
タイプ
quitシステムのシェルに戻ります。
10 Courier-IMAP/Courier-POP3
MaildirサポートのあるPOP3/IMAPデーモンを使用したいと思います。 そのため、Courier-IMAPとCourier-POP3を使用します。
yast2 -i courier-imap fam-server courier-authlib expect tclその後、システム起動リンクを追加し、POP3、IMAP、POP3s、およびIMAPsを起動します。
chkconfig –add fam
chkconfig –add courier-authdaemon
chkconfig –add courier-pop
chkconfig –add courier-imap
/etc/init.d/courier-pop start
/etc/init.d/courier-imap start
chkconfig –add courier-pop-ssl
chkconfig –add courier-imap-ssl
/etc/init.d/courier-pop-ssl start
/etc/init.d/courier-imap-ssl start
ISPConfigを使用しない場合は、Postfixを構成してユーザーのMaildirにメールを配信します。
postconf -e ‘home_mailbox = Maildir/‘
postconf -e ‘mailbox_command =’
/etc/init.d/postfix restart
*注意: ISPConfigをシステムで使用する予定の場合は、これを行う必要はありません(しかし、行っても問題ありません;-)ISPConfigはprocmailレシピを使用して必要な構成を行います。ただし、ISPConfigのWebインターフェースの管理 -> サーバー -> 設定 -> EメールでMaildirを有効にすることを確認してください。
新しい投稿を受信箱で受け取る
スパムはありません。いつでも購読を解除できます。