Apache 2.2.26(RPM)
の編集
http://www.abetake.com/pukiwiki/?Apache+2.2.26%28RPM%29
[
トップ
] [
編集
|
差分
|
履歴
|
添付
|
リロード
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
]
-- 雛形とするページ --
(no template pages)
''目次'' #contents ~ ---- ~ ※[[RPM]]も参照の事。~ ~ *準備 [#bdf7987c] -インストール済みのパッケージを削除 # yum remove httpd apr apr-util ~ -[[APR 1.5.0(RPM)]] のインストール~ ~ -[[APR-util 1.5.3(RPM)]] のインストール~ ~ - distcache-devel のインストール~ リポジトリに含まれていない為,、 Fedora から SRPM を持ってきてリビルド後インストール. ~ # su - rpmdevel $ cd /home/rpmdevel/src $ wget http://ftp.riken.jp/Linux/fedora/releases/18/Everything/source/SRPMS/d/distcache-1.4.5-23.src.rpm $ rpmbuild --rebuild distcache-1.4.5-23.src.rpm $ cd /home/rpmdevel/rpm/RPMS/i686 $ sudo rpm -Uvh distcache-1.4.5-23.i686.rpm $ sudo rpm -Uvh distcache-devel-1.4.5-23.i686.rpm ~ -必要なものを yum でインストールする # yum -y install pcre-devel ~ *インストール [#x0b60073] +ソースの取得~ # su - rpmdevel $ cd /home/rpmdevel/src $ wget http://ftp.riken.jp/net/apache/httpd/httpd-2.2.26.tar.gz ~ +''RPMの作成'' $ rpmbuild -tb --clean httpd-2.2.26.tar.gz ~ +''インストール'' $ cd /home/rpmdevel/rpm/RPMS/i686 $ sudo rpm -Uvh httpd-2.2.26-1.i686.rpm $ sudo rpm -Uvh httpd-devel-2.2.26-1.i686.rpm $ sudo rpm -Uvh mod_ssl-2.2.26-1.i686.rpm ~ *初期設定 [#j2088014] -''httpd.confの設定'' # vi /etc/httpd/conf/httpd.conf ユーザーとグループの変更 User daemon Group daemon ↓ User apache Group apache サーバー名の設定 ServerName www.example.com:80 ↓ ServerName XXXXXXXXXXX:80 *SSL対応設定 [#ea529495] **認証局(CA)の構築 [#qb4ba4f0] -秘密鍵と証明書の作成~ CA.shという用意されたスクリプトを使用 # cd /etc/pki/tls # cp misc/CA . # ./CA -newca CA certificate filename (or enter to create) ← 空Enter Making CA certificate ... Generating a 1024 bit RSA private key .....++++++ ................++++++ writing new private key to '/etc/pki/CA/private/./cakey.pem' Enter PEM pass phrase: ← 秘密鍵のパスフレーズを入力 Verifying password - Enter PEM pass phrase: ← もう一度入力 ----- You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [AU]: ← JP State or Province Name (full name) [Some-State]: ← 県名 Locality Name (eg, city) []: ← 市町村 Organization Name (eg, company) [Internet Widgits Pty Ltd]:← 社名 Organizational Unit Name (eg, section) []: ← 部署 Common Name (eg, YOUR name) []: ← (※) Email Address []: ← メルアド Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: ← 空Enter An optional company name []: ← 空Enter Enter pass phrase for /etc/pki/CA/private/./cakey.pem: ← 秘密鍵のパスフレーズを入力 (※)サーバのURL(またはサーバ名?)にしないとApacheLogに警告が出力されてた。 以上の処理により、~ ~ /etc/pki/CA/cacert.pem ← 自己署名型CA証明書~ /etc/pki/CA/private/cakey.pem ← 秘密鍵~ ~ が作成される。~ 秘密鍵は他人に見られないように # chmod 600 /etc/pki/CA/private/cakey.pem # chmod 700 /etc/pki/CA/private とパーミッションを設定しておく。~ 証明書を確認するには以下のようにする。 # openssl x509 -in /etc/pki/CA/cacert.pem -text **SSLサーバ構築 [#p4db68bc] -サーバ秘密鍵の作成 # openssl genrsa -out server.key 1024 Generating RSA private key, 1024 bit long modules .............++++++ ....++++++ e is 65537 (0x10001) 確認 # ls server.key -証明書署名要求(CSR)の作成 # openssl req -new -key server.key -out server.csr You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [AU]: ← JP State or Province Name (full name) [Some-State]: ← 県名 Locality Name (eg, city) []: ← 市町村 Organization Name (eg, company) [Internet Widgits Pty Ltd]:← 社名 Organizational Unit Name (eg, section) []: ← 部署 Common Name (eg, YOUR name) []: ← (※) Email Address []: ← メルアド Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: ← 空Enter An optional company name []: ← 空Enter (※)サーバのURL(またはサーバ名?)にしないとApacheLogに警告が出力されてた。 確認 # ls server.key server.csr -証明書への自己署名 # echo 01 > ca-cert.srl # openssl x509 -CA ../CA/cacert.pem -CAkey ../CA/private/cakey.pem -CAserial ca-cert.srl -req -days 3650 -in server.csr -out server.crt Using configuration from /etc/pki/tls/openssl.cnf Enter pass phrase for /etc/pki/CA/private/cakey.pem: ← 秘密鍵のパスフレーズを入力 確認 # ls server.key server.csr server.crt 秘密鍵と証明書を移動する。 # mkdir /etc/httpd/conf/ssl # mv server.key /etc/httpd/conf/ssl # mv server.crt /etc/httpd/conf/ssl **Apacheへの埋め込み [#fb362adc] -''httpd-ssl.confの設定'' # vi /etc/httpd/conf/extra/httpd-ssl.conf サーバー名 <VirtualHost _default_:443> ServerName www.example.com:443 ↓ ServerName XXXXXXXXXXXXXXX:443 サーバー証明書のパス SSLCertificateFile "/etc/httpd/conf/server.crt" ↓ SSLCertificateFile "/etc/httpd/conf/ssl/server.crt" 秘密鍵のパス SSLCertificateKeyFile "/etc/httpd/conf/server.key" ↓ SSLCertificateKeyFile "/etc/httpd/conf/ssl/server.key" -''httpd.confの設定'' SSL用設定ファイルの有効化 # vi /etc/httpd/conf/httpd.conf SSL設定ファイルのリンク # Secure (SSL/TLS) connections #Include conf/extra/httpd-ssl.conf ↓ Include conf/extra/httpd-ssl.conf ← コメント外す 確認 # /usr/sbin/apachectl configtest Syntax OK *起動 [#l58249df] 下記のコマンドで起動、停止、再起動を行う # /usr/sbin/apachectl start ← 起動 # /usr/sbin/apachectl stop ← 停止 # /usr/sbin/apachectl restart ← 再起動 *動作確認 [#z82ab4b3] http,httpsでそれぞれアクセスし「It works!」が表示されればOK。~ ~ *自動起動設定 [#l37381a1] # chkconfig httpd on ~ *有効にしているモジュール [#ye1b3c2d] 大層な数のモジュールが動作しているので、下記に限定して他は無効化。~ (とりあえず)~ LoadModule authz_host_module /usr/lib/httpd/modules/mod_authz_host.so →[[authz_host_module>http://httpd.apache.org/docs/2.2/ja/mod/mod_authz_host.html]] のドキュメント~ ~ LoadModule log_config_module /usr/lib/httpd/modules/mod_log_config.so →[[log_config_module>http://httpd.apache.org/docs/2.2/ja/mod/mod_log_config.html]] のドキュメント~ ~ LoadModule setenvif_module /usr/lib/httpd/modules/mod_setenvif.so →[[setenvif_module>http://httpd.apache.org/docs/2.2/ja/mod/mod_setenvif.html]] のドキュメント~ ~ LoadModule ssl_module /usr/lib/httpd/modules/mod_ssl.so →[[ssl_module>http://httpd.apache.org/docs/2.2/ja/mod/mod_ssl.html]] のドキュメント~ ~ LoadModule mime_module /usr/lib/httpd/modules/mod_mime.so →[[mime_module>http://httpd.apache.org/docs/2.2/ja/mod/mod_mime.html]] のドキュメント~ ~ LoadModule dav_module /usr/lib/httpd/modules/mod_dav.so →[[dav_module>http://httpd.apache.org/docs/2.2/ja/mod/mod_dav.html]] のドキュメント~ ~ LoadModule dav_fs_module /usr/lib/httpd/modules/mod_dav_fs.so →[[dav_fs_module>http://httpd.apache.org/docs/2.2/ja/mod/mod_dav_fs.html]] のドキュメント~ ~ LoadModule rewrite_module /usr/lib/httpd/modules/mod_rewrite.so →[[rewrite_module>http://httpd.apache.org/docs/2.2/ja/mod/mod_rewrite.html]] のドキュメント~ ~ LoadModule dav_svn_module /usr/lib/httpd/modules/mod_dav_svn.so →[[dav_svn_module>http://www.caldron.jp/~nabetaro/svn/svnbook-1.5-final/html-chunk/svn.ref.mod_dav_svn.conf.html]] のドキュメント~ ~
タイムスタンプを変更しない
''目次'' #contents ~ ---- ~ ※[[RPM]]も参照の事。~ ~ *準備 [#bdf7987c] -インストール済みのパッケージを削除 # yum remove httpd apr apr-util ~ -[[APR 1.5.0(RPM)]] のインストール~ ~ -[[APR-util 1.5.3(RPM)]] のインストール~ ~ - distcache-devel のインストール~ リポジトリに含まれていない為,、 Fedora から SRPM を持ってきてリビルド後インストール. ~ # su - rpmdevel $ cd /home/rpmdevel/src $ wget http://ftp.riken.jp/Linux/fedora/releases/18/Everything/source/SRPMS/d/distcache-1.4.5-23.src.rpm $ rpmbuild --rebuild distcache-1.4.5-23.src.rpm $ cd /home/rpmdevel/rpm/RPMS/i686 $ sudo rpm -Uvh distcache-1.4.5-23.i686.rpm $ sudo rpm -Uvh distcache-devel-1.4.5-23.i686.rpm ~ -必要なものを yum でインストールする # yum -y install pcre-devel ~ *インストール [#x0b60073] +ソースの取得~ # su - rpmdevel $ cd /home/rpmdevel/src $ wget http://ftp.riken.jp/net/apache/httpd/httpd-2.2.26.tar.gz ~ +''RPMの作成'' $ rpmbuild -tb --clean httpd-2.2.26.tar.gz ~ +''インストール'' $ cd /home/rpmdevel/rpm/RPMS/i686 $ sudo rpm -Uvh httpd-2.2.26-1.i686.rpm $ sudo rpm -Uvh httpd-devel-2.2.26-1.i686.rpm $ sudo rpm -Uvh mod_ssl-2.2.26-1.i686.rpm ~ *初期設定 [#j2088014] -''httpd.confの設定'' # vi /etc/httpd/conf/httpd.conf ユーザーとグループの変更 User daemon Group daemon ↓ User apache Group apache サーバー名の設定 ServerName www.example.com:80 ↓ ServerName XXXXXXXXXXX:80 *SSL対応設定 [#ea529495] **認証局(CA)の構築 [#qb4ba4f0] -秘密鍵と証明書の作成~ CA.shという用意されたスクリプトを使用 # cd /etc/pki/tls # cp misc/CA . # ./CA -newca CA certificate filename (or enter to create) ← 空Enter Making CA certificate ... Generating a 1024 bit RSA private key .....++++++ ................++++++ writing new private key to '/etc/pki/CA/private/./cakey.pem' Enter PEM pass phrase: ← 秘密鍵のパスフレーズを入力 Verifying password - Enter PEM pass phrase: ← もう一度入力 ----- You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [AU]: ← JP State or Province Name (full name) [Some-State]: ← 県名 Locality Name (eg, city) []: ← 市町村 Organization Name (eg, company) [Internet Widgits Pty Ltd]:← 社名 Organizational Unit Name (eg, section) []: ← 部署 Common Name (eg, YOUR name) []: ← (※) Email Address []: ← メルアド Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: ← 空Enter An optional company name []: ← 空Enter Enter pass phrase for /etc/pki/CA/private/./cakey.pem: ← 秘密鍵のパスフレーズを入力 (※)サーバのURL(またはサーバ名?)にしないとApacheLogに警告が出力されてた。 以上の処理により、~ ~ /etc/pki/CA/cacert.pem ← 自己署名型CA証明書~ /etc/pki/CA/private/cakey.pem ← 秘密鍵~ ~ が作成される。~ 秘密鍵は他人に見られないように # chmod 600 /etc/pki/CA/private/cakey.pem # chmod 700 /etc/pki/CA/private とパーミッションを設定しておく。~ 証明書を確認するには以下のようにする。 # openssl x509 -in /etc/pki/CA/cacert.pem -text **SSLサーバ構築 [#p4db68bc] -サーバ秘密鍵の作成 # openssl genrsa -out server.key 1024 Generating RSA private key, 1024 bit long modules .............++++++ ....++++++ e is 65537 (0x10001) 確認 # ls server.key -証明書署名要求(CSR)の作成 # openssl req -new -key server.key -out server.csr You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [AU]: ← JP State or Province Name (full name) [Some-State]: ← 県名 Locality Name (eg, city) []: ← 市町村 Organization Name (eg, company) [Internet Widgits Pty Ltd]:← 社名 Organizational Unit Name (eg, section) []: ← 部署 Common Name (eg, YOUR name) []: ← (※) Email Address []: ← メルアド Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: ← 空Enter An optional company name []: ← 空Enter (※)サーバのURL(またはサーバ名?)にしないとApacheLogに警告が出力されてた。 確認 # ls server.key server.csr -証明書への自己署名 # echo 01 > ca-cert.srl # openssl x509 -CA ../CA/cacert.pem -CAkey ../CA/private/cakey.pem -CAserial ca-cert.srl -req -days 3650 -in server.csr -out server.crt Using configuration from /etc/pki/tls/openssl.cnf Enter pass phrase for /etc/pki/CA/private/cakey.pem: ← 秘密鍵のパスフレーズを入力 確認 # ls server.key server.csr server.crt 秘密鍵と証明書を移動する。 # mkdir /etc/httpd/conf/ssl # mv server.key /etc/httpd/conf/ssl # mv server.crt /etc/httpd/conf/ssl **Apacheへの埋め込み [#fb362adc] -''httpd-ssl.confの設定'' # vi /etc/httpd/conf/extra/httpd-ssl.conf サーバー名 <VirtualHost _default_:443> ServerName www.example.com:443 ↓ ServerName XXXXXXXXXXXXXXX:443 サーバー証明書のパス SSLCertificateFile "/etc/httpd/conf/server.crt" ↓ SSLCertificateFile "/etc/httpd/conf/ssl/server.crt" 秘密鍵のパス SSLCertificateKeyFile "/etc/httpd/conf/server.key" ↓ SSLCertificateKeyFile "/etc/httpd/conf/ssl/server.key" -''httpd.confの設定'' SSL用設定ファイルの有効化 # vi /etc/httpd/conf/httpd.conf SSL設定ファイルのリンク # Secure (SSL/TLS) connections #Include conf/extra/httpd-ssl.conf ↓ Include conf/extra/httpd-ssl.conf ← コメント外す 確認 # /usr/sbin/apachectl configtest Syntax OK *起動 [#l58249df] 下記のコマンドで起動、停止、再起動を行う # /usr/sbin/apachectl start ← 起動 # /usr/sbin/apachectl stop ← 停止 # /usr/sbin/apachectl restart ← 再起動 *動作確認 [#z82ab4b3] http,httpsでそれぞれアクセスし「It works!」が表示されればOK。~ ~ *自動起動設定 [#l37381a1] # chkconfig httpd on ~ *有効にしているモジュール [#ye1b3c2d] 大層な数のモジュールが動作しているので、下記に限定して他は無効化。~ (とりあえず)~ LoadModule authz_host_module /usr/lib/httpd/modules/mod_authz_host.so →[[authz_host_module>http://httpd.apache.org/docs/2.2/ja/mod/mod_authz_host.html]] のドキュメント~ ~ LoadModule log_config_module /usr/lib/httpd/modules/mod_log_config.so →[[log_config_module>http://httpd.apache.org/docs/2.2/ja/mod/mod_log_config.html]] のドキュメント~ ~ LoadModule setenvif_module /usr/lib/httpd/modules/mod_setenvif.so →[[setenvif_module>http://httpd.apache.org/docs/2.2/ja/mod/mod_setenvif.html]] のドキュメント~ ~ LoadModule ssl_module /usr/lib/httpd/modules/mod_ssl.so →[[ssl_module>http://httpd.apache.org/docs/2.2/ja/mod/mod_ssl.html]] のドキュメント~ ~ LoadModule mime_module /usr/lib/httpd/modules/mod_mime.so →[[mime_module>http://httpd.apache.org/docs/2.2/ja/mod/mod_mime.html]] のドキュメント~ ~ LoadModule dav_module /usr/lib/httpd/modules/mod_dav.so →[[dav_module>http://httpd.apache.org/docs/2.2/ja/mod/mod_dav.html]] のドキュメント~ ~ LoadModule dav_fs_module /usr/lib/httpd/modules/mod_dav_fs.so →[[dav_fs_module>http://httpd.apache.org/docs/2.2/ja/mod/mod_dav_fs.html]] のドキュメント~ ~ LoadModule rewrite_module /usr/lib/httpd/modules/mod_rewrite.so →[[rewrite_module>http://httpd.apache.org/docs/2.2/ja/mod/mod_rewrite.html]] のドキュメント~ ~ LoadModule dav_svn_module /usr/lib/httpd/modules/mod_dav_svn.so →[[dav_svn_module>http://www.caldron.jp/~nabetaro/svn/svnbook-1.5-final/html-chunk/svn.ref.mod_dav_svn.conf.html]] のドキュメント~ ~
テキスト整形のルールを表示する