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

完璧なサーバー - Mandriva 2008 Free (Mandriva 2008.0) - ページ 5

10 MySQL (5.0)

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

urpmi MySQL MySQL-client libmysql15-devel

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

vi /etc/my.cnf

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

その後、MySQLを起動します:

/etc/init.d/mysqld start

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

netstat -tap | grep mysql

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

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

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

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

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

11 Postfix With SMTP-AUTH And TLS

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

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 imap

次に、次のコマンドを実行します(mydomain、myhostname、およびmydestinationの正しい値を使用していることを確認してください):

postconf -e 'mydomain = example.com'  
postconf -e 'myhostname = server1.$mydomain'  
postconf -e 'mydestination = /etc/postfix/local-host-names, localhost.example.com'  
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'  
postconf -e 'mynetworks = 127.0.0.0/8'  
touch /etc/postfix/local-host-names  
touch /var/lib/mailman/data/aliases

/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'

次に、Postfix、saslauthd、imap、およびpop3を起動します:

chkconfig imap on  
chkconfig imaps on  
chkconfig ipop3 on  
chkconfig pop3s on  
/etc/init.d/postfix restart  
/etc/init.d/saslauthd restart  
/etc/init.d/xinetd 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.4.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 ssl]#
quit

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

12 Apache2 With PHP5

Apache2とPHP5をインストールするには、次のコマンドを実行します(1行で):

urpmi apache-mod_suexec apache-mod_ssl apache-mod_php libphp5_common5 php-bz2 php-calendar php-ctype php-curl php-devel php-dio php-dom php-eaccelerator php-enchant php-esmtp php-event php-exif php-fam php-ffmpeg php-fileinfo php-filepro php-ftp php-gd php-gettext php-gmp php-iconv php-id3 php-idn php-imap php-imlib2 php-mailparse php-mbstring php-mcache php-mcrypt php-mhash php-ming php-mysql php-mysqli php-ncurses php-newt php-odbc php-oggvorbis php-pam_auth php-pcntl php-pcre php-pear-Net_IDNA php-posix php-pspell php-readline php-recode php-session php-shmop php-simplexml php-snmp php-soap php-sockets php-sqlite php-ssh2 php-suhosin php-sysvmsg php-sysvsem php-sysvshm php-tclink php-tcpwrap php-tidy php-xml php-xmlrpc php-zip php-ini curl libcurl4-devel perl-libwww-perl ImageMagick

Apacheを起動します:

/etc/init.d/httpd restart

12.1 PHPをグローバルに無効にする

(このサーバーにISPConfigをインストールする予定がない場合は、このセクションをスキップしてください!)

ISPConfigでは、ウェブサイトごとにPHPを設定します。つまり、どのウェブサイトがPHPスクリプトを実行でき、どのウェブサイトが実行できないかを指定できます。これは、PHPがグローバルに無効になっている場合にのみ機能します。そうでないと、すべてのウェブサイトがISPConfigで指定した内容に関係なくPHPスクリプトを実行できてしまいます。

/etc/httpd/modules.d/70_mod_php.confを編集し、AddType行をコメントアウトします:

vi /etc/httpd/modules.d/70_mod_php.conf

| LoadModule php5_module extramodules/mod_php5.so # AddType application/x-httpd-php .php # AddType application/x-httpd-php .phtml # AddType application/x-httpd-php-source .phps DirectoryIndex index.php index.phtml |

/etc/httpd/conf/httpd.confを編集し、LoadModuleセクションに次の行を追加します:

vi /etc/httpd/conf/httpd.conf

| [...] LoadModule php5_module extramodules/mod_php5.so [...] |

(この行はすでに/etc/httpd/modules.d/70_mod_php.confにありますが、これは非常に重要です。そうでないと、ISPConfigによって作成された仮想ホストにphp_admin_flag safe_mode Onのような行が含まれている場合、コマンド

httpd -t

はSyntax OKではなくエラーを報告します!)

Apacheを再起動します:

/etc/init.d/httpd restart
Share: X/Twitter LinkedIn

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

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