Apache2+ssl 的设定方法
来源:互联网 发布:烟草允许网络售卖吗 编辑:程序博客网 时间:2024/05/20 21:47
Apache2 + SSL の設定方法 (Linuxの場合)
●プライベート証明書の作成(第三者機関に頼らず自分で作成する)
server.key はディレクトリ ssl.key に移動させます。
●パブリック証明書の作成(第三者認証機関を利用)
■すぐにSSLサーバ証明書が必要な方へ!
これをベリサインなどに伝えます。
パスフレーズを入力してください。
●自動起動の設定 (Redhat 9での例)
クレッジットカードなどの決済を行いたい場合には、WebサーバーをSSL 対応にする必要があります。
SSL対応 Apache をご利用になりたい方は下記のように設定してください。
http://httpd.apache.org/から httpd-2.0.54.tar.gz をダウンロードし、/usr/local/src/ に置く。
インストール手順は下記のようになります。% cd /usr/local/src% tar zxvf httpd-2.0.54.tar.gz% cd httpd-2.0.54% ./configure --enable-so --enable-ssl% make% make installSSLの設定に移ります。% cd /usr/local/apache2/confそこで2つのディレクトリを作成します。% mkdir ssl.crt % mkdir ssl.key
●プライベート証明書の作成(第三者機関に頼らず自分で作成する)
% cd /usr/local/apache2/conf/ssl.crt% openssl req -new -x509 -nodes -out server.crt -keyout server.key -days 365いくつか質問されますので、答えます。
Country Name (2 letter code) [AU]:JPState or Province Name (full name) [Some-State]:TokyoLocality Name (eg, city) []:Shinagawa-kuOrganization Name (eg, company) [Internet Widgits Pty Ltd]:RAT Co.,Ltd.Organizational Unit Name (eg, section) []:Common Name (eg, YOUR name) []:platz.jpEmail Address []:info@platz.jp同じフォルダに SSL の秘密鍵 server.key とプライベート証明書 server.crt ができます。
server.key はディレクトリ ssl.key に移動させます。
% mv server.key ../ssl.key/
実行は下記のようにしましょう。
% /usr/local/apache2/bin/httpd -DSSL
●パブリック証明書の作成(第三者認証機関を利用)
■すぐにSSLサーバ証明書が必要な方へ!
1. 疑似乱数の生成
% cd /usr/local/apache2/conf% openssl md5 * > rand.dat2. 秘密鍵ファイル(server.key)の作成
% openssl genrsa -rand rand.dat -des3 1024 > ssl.key/server.key秘密鍵を保護するためのパスフレーズの入力を求められます。ここで入力したパスフレーズは後で必要になるので、覚えておいてください。また、一般ユーザーが見れないように属性を変更します。% chmod 600 ssl.key/server.key3. CSR の作成
% openssl req -new -key ssl.key/server.key -out csr.pem秘密鍵のパスフレーズを入力します。証明書に表示される情報を入力していきます。(必要なければ単に改行だけ押してください)Country Name (2 letter code) [AU]:JPState or Province Name (full name) [Some-State]:TokyoLocality Name (eg, city) []:Shinagawa-kuOrganization Name (eg, company) [Internet Widgits Pty Ltd]:RAT Co.,Ltd.Organizational Unit Name (eg, section) []:Common Name (eg, YOUR name) []:Email Address []:Please enter the following 'extra' attributesto be sent with your certificate requestA challenge password []:An optional company name []:同じフォルダに CSR である csr.pem ができます。
これをベリサインなどに伝えます。
4. サーバーIDの保存
サーバID通知メールを送られてくるので、「-----BEGIN CERTIFICATE-----」から「-----END CERTIFICATE-----」までをこれらの2行も含めて、server.crt のファイル名で保存します。これを /usr/local/apache2/conf/ssl.crt/ に置いておきます。実行は下記のようにしましょう。
% /usr/local/apache2/bin/httpd -DSSLパスフレーズを聞かれますので、server.key を作成したときに設定した
パスフレーズを入力してください。
○パスフレーズを入力しないで起動する方法
自動起動する場合などは、パスフレーズの入力を外す必要があります。
% cd /usr/local/apache2/conf/ssk.key% openssl rsa -in server.key -out server_nopass.key% chmod 600 server_nopass.key/usr/local/apache2/conf/ssl.conf を1ヶ所変更してください。
SSLCertificateKeyFile /usr/local/apache2/conf/ssl.key/server_nopass.keyパスフレーズの入力なしで起動することができるようになります。
●自動起動の設定 (Redhat 9での例)
1. /etc/rc.d/init.d/httpd のファイルを下記のように修正します。2. % chkconfig --level 3 httpd on を実行する。 /etc/rc.d/init.d/httpd stop /etc/rc.d/init.d/httpd start で起動、終了ができるようになります。SSL対応なしで、Apache を起動させる場合には、"OPTIONS=-DSSL" の部分をコメントにしてください。
#!/bin/bash## Startup script for the Apache Web Server## chkconfig: - 85 15# description: Apache is a World Wide Web server. It is used to serve /# HTML files and CGI.# processname: httpd# pidfile: /var/run/httpd.pid# config: /etc/httpd/conf/httpd.conf# Source function library.. /etc/rc.d/init.d/functionsif [ -f /etc/sysconfig/httpd ]; then . /etc/sysconfig/httpdfi# This will prevent initlog from swallowing up a pass-phrase prompt if# mod_ssl needs a pass-phrase from the user.INITLOG_ARGS=""# Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server# with the thread-based "worker" MPM; BE WARNED that some modules may not# work correctly with a thread-based MPM; notably PHP will refuse to start.# Path to the apachectl script, server binary, and short-form for messages.##apachectl=/usr/sbin/apachectlapachectl=/usr/local/apache2/bin/apachectl##httpd=${HTTPD-/usr/sbin/httpd}httpd=${HTTPD-/usr/local/apache2/bin/httpd}OPTIONS=-DSSLprog=httpdRETVAL=0# check for 1.3 configurationcheck13 () { CONFFILE=/etc/httpd/conf/httpd.conf GONE="(ServerType|BindAddress|Port|AddModule|ClearModuleList|" GONE="${GONE}AgentLog|RefererLog|RefererIgnore|FancyIndexing|" GONE="${GONE}AccessConfig|ResourceConfig)" if grep -Eiq "^[[:space:]]*($GONE)" $CONFFILE; then echo echo 1>&2 " Apache 1.3 configuration directives found" echo 1>&2 " please read /usr/share/doc/httpd-2.0.40/migration.html" failure "Apache 1.3 config directives test" echo exit 1 fi}# The semantics of these two functions differ from the way apachectl does# things -- attempting to start while running is a failure, and shutdown# when not running is also a failure. So we just do it the way init scripts# are expected to behave here.start() { echo -n ___FCKpd___11quot;Starting $prog: " check13 || exit 1 daemon $httpd $OPTIONS RETVAL=$? echo [ $RETVAL = 0 ] && touch /var/lock/subsys/httpd return $RETVAL}stop() { echo -n ___FCKpd___11quot;Stopping $prog: " killproc $httpd RETVAL=$? echo## [ $RETVAL = 0 ] && rm -f /var/lock/subsys/httpd /var/run/httpd.pid [ $RETVAL = 0 ] && rm -f /var/lock/subsys/httpd /usr/local/apache2/logs/httpd.pid}reload() { echo -n ___FCKpd___11quot;Reloading $prog: " check13 || exit 1 killproc $httpd -HUP RETVAL=$? echo}# See how we were called.case "$1" in start) start ;; stop) stop ;; status) status $httpd RETVAL=$? ;; restart) stop start ;; condrestart)## if [ -f /var/run/httpd.pid ] ; then if [ -f /usr/local/apache2/logs/httpd.pid ] ; then stop start fi ;; reload) reload ;; graceful|help|configtest|fullstatus) $apachectl $@ RETVAL=$? ;; *) echo ___FCKpd___11quot;Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}" exit 1esacexit $RETVAL
- Apache2+ssl 的设定方法
- debian 下的 apache2 + ssl 配置方法
- 原文转载:Apache2中的SSL设定
- 还是tomcat的ssl设定
- apache2 + ssl
- apache2.2下配置SSL 的过程
- linux下apache2+php+ssl的安装
- Debian 下配置 apache2 的 SSL
- 有关linux下apache2的ssl
- mac下的apache2配置ssl
- linux debian系统配置apache2的SSL证书
- 设定闹钟的方法
- Apache2下配置SSL
- apache2 配置ssl
- HOWTO - Apache2 + Subversion + SSL
- apache2 ssl 双向认证
- apache2 ssl 认证
- apache2.2添加ssl
- UDP编程问题
- 升华思想境界,走出博士的专家路线 --转载
- 2-Windows 窗体应用程序模型
- oracle数据库优化
- ASP.NET中使用自定义验证控件
- Apache2+ssl 的设定方法
- 使用HttpContext的User属性来实现用户验证
- CSS首行缩进背景色透明强制换行等
- asp.net 中使用sqlcommandbuilder
- 一个比较难杀的木马下载器 kndncso.exe jvxnypf.exe cmdbcs.exe lRAVWL.EXE
- Tomcat下中文问题的最有效及全面的解决教程
- php设计模式介绍(书摘)一
- 人际沟通黄金四原则
- 如何取消开机时按F1才能继续的设置