Dell Optiplex GXa Solaris 8  x86  6/00

戻る




Apache/1.3.23 (Unix) mod_perl/1.26 mod_ssl/2.8.6 OpenSSL/0.9.6c

※後に現在の最新の、
Apache/2.0.48 (Unix) mod_perl/1.99_10 Perl/v5.8.0 PHP/4.3.3 DAV/2 mod_ssl/2.0.48 OpenSSL/0.9.7c
の記録あり。


	※※ 注 ※※
	 Apache以下のバージョンは、DoS攻撃に対する脆弱性になり得る
	 セキュリティホールがある事が判明しています。

	 1.2 系列: バージョン 1.2.2  以降
	 1.3 系列: バージョン 1.3.24 以前
	 2.0 系列: バージョン 2.0.36 以前

	 1.3.26以降または2.0.39以降にバージョンアップされる事を
	 お奨めします。
	 詳細は
	 http://www.cert.org/advisories/CA-2002-17.html
	 http://httpd.apache.org/info/security_bulletin_20020617.txt


必要なソフトウェア:

apache_1.3.23.tar.gz
http://www.apache.org/dist/httpd/

openssl-engine-0.9.6c.tar.gz
http://www.openssl.org/source/

mod_ssl-2.8.6-1.3.23.tar.gz
http://www.modssl.org/source/

mod_perl-1.26.tar.gz
http://perl.apache.org/dist/


準備

作業ディレクトリを作成し、移動しておく。
	$ mkdir /opt/src/apache1.3.23
	$ cd /opt/src/apache1.3.23


apacheの解凍展開

アーカイブをダウンロードする。
	$ wget http://www.apache.org/dist/httpd/apache_1.3.23.tar.gz

解凍展開しておく。
	$ tar xozf apache_1.3.23.tar.gz

	
OpenSSL (0.9.6c) のインストール

アーカイブをダウンロードする。
	$ wget http://www.openssl.org/source/openssl-engine-0.9.6c.tar.gz

解凍展開する。
	$ tar xozf ./openssl-engine-0.9.6c.tar.gz

SuperUserになる。
	$ su
	password:

オーナーとグループを変更しておく
	# chown -R root:other openssl-engine-0.9.6c

解凍展開されたディレクトリに移る。
	# cd openssl-engine-0.9.6c

最適化する。
	# ./config

コンパイルする。
	# make

テストする。
	# make test
	
===============================================
Approximate total server time:   0.44 s
Approximate total client time:   1.27 s
make[1]: Leaving directory `/opt/src/apache1.3.23/openssl-engine-0.9.6c/test'
OpenSSL 0.9.6c [engine] 21 dec 2001
built on: 2002年02月02日 (土) 00時15分53秒 JST
platform: solaris-x86-gcc
options:  bn(64,32) md2(int) rc4(idx,int) des(ptr,risc1,16,long) idea(int) blowf
ish(idx)
compiler: gcc -fPIC -DTHREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -O3 -fomit
-frame-pointer -m486 -Wall -DL_ENDIAN -DNO_INLINE_ASM -DSHA1_ASM -DMD5_ASM -DRMD
160_ASM
===============================================


ってなメッセージが出れば成功。


SuperUserになってインストールする。
	# make install
	# exit
	$ cd ../

	
mod_ssl-2.8.6-1.3.23の解凍展開コンパイル

アーカイブをダウンロード
	$ wget http://www.modssl.org/source/mod_ssl-2.8.6-1.3.23.tar.gz

解凍展開する。
	$ tar xozf mod_ssl-2.8.6-1.3.23.tar.gz

ディレクトリを移る。
	$ cd mod_ssl-2.8.6-1.3.23

最適化する。
	$ ./configure --with-apache=../apache_1.3.23 \
		--with-ssl=../openssl-engine-0.9.6c \
		--prefix=/usr/local/apache

ディレクトリを戻っておく。
	$ cd ../

	
mod_perl-1.26の解凍展開インストール 

アーカイブをダウンロードする。
	$ wget http://perl.apache.org/dist/mod_perl-1.26.tar.gz

解凍展開する。
	$ tar xozf mod_perl-1.26.tar.gz

ディレクトリを移動する。
	$ cd mod_perl-1.26

Makefile Perlスクリプトを実行する。
	$ perl Makefile.PL APACHE_SRC=../apache_1.3.23/src \
		DO_HTTPD=1 \
		USE_APACI=1 \
		PREP_HTTPD=1 \
		EVERYTHING=1
 
makeする。
	$ make

SuperUserになって、インストールする
	$ su
	password:
	# make install
	# exit

ディレクトリを戻っておく。
	$ cd ../


Apache_1.3.23のインストール

もしも、既に以前のバージョンのapacheが/usr/local/apacheにインストールされていたら、
httpd.confの名前を変更しておく。(httpd.confが既に存在していると、インストールしても上書きさ
れないため)
	$ su
	password:
	# mv /usr/local/apache/conf/httpd.conf /usr/local/apache/conf/httpd.conf.old
	# exit

ディレクトリを移動する。
	$ cd ./apache1.3.23/src

Configurationファイルをviで開く。
	$ vi Configuration

以下の項目のコメントアウトを外して保存終了させる

===========================================================
Addmodule modules/standard/mod_log_agent.o
アクセスしてきたプラウザが名乗ったプラウザの種類を記録するためのモジュール。

Addmodule modules/standard/mod_log_referer.o
アクセスしてきたプラウザが示した、「どこの URL からたどってきた のか」という情報を記録する
ためのモジュール。

Addmodule modules/standard/mod_rewrite.o
要求された URL について正規表現を利用した書き換えを行うモジュール。

AddModule modules/standard/mod_so.o
動的モジュールを有効にするモジュール。
===========================================================


ひとつ上のディレクトリに移動する。
	$ cd ..

$ 最適化する。
	./configure --enable-module=ssl \
		--activate-module=src/modules/perl/libperl.a \
		--enable-module=so \
		--enable-module=rewrite

makeする。
	$ make

SuperUserになってインストールする。
	$ su
	password:
	# make install



証明書発行

Key を生成する際は、ランダムな情報を入力する必要がるが、例えば以下のようにすることで作成
が可能
	# cd /usr/local/ssl/bin
	# ./openssl md5 * > rand.dat 

Private Key を作成する。
	# ./openssl genrsa -rand ./rand.dat -des 1024 > /usr/local/ssl/private/key.pem
	
===========================================================
95 semi-random bytes loaded
Generating RSA private key, 1024 bit long modulus
.................++++++
....................++++++
e is 65537 (0x10001)
Enter PEM pass phrase: **********
Verifying password - Enter PEM pass phrase: **********
===========================================================


Private Key からパスフレーズを外す。
	# ./openssl rsa -in /usr/local/ssl/private/key.pem -out /usr/local/ssl/private/key2.pem
	read RSA key
	Enter PEM pass phrase:
	writing RSA key 

	
今回は認証局に依頼せず、自分で署名した証明を作成するので、下記のようになる。
	# ./openssl req -new -x509 -key /usr/local/ssl/private/key2.pem -out /usr/local/ssl/certs/cert.pem

===========================================================
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]:Tokyo
Locality Name (eg, city) []:T0shima-ku
Organization Name (eg, company) [Internet Widgits Pty Ltd]:domain
Organizational Unit Name (eg, section) []:tech
Common Name (eg, YOUR name) []:www.domain.com
Email Address []:you@domain.com
===========================================================


httpd.confを修正する。

念のためデフォルトのhttpd.confのバックアップを取っておく。
	# cp /usr/local/apache/conf/httpd.conf /usr/local/apache/conf/httpd.conf.default

viでhttpd.confを開く。
	# vi /usr/local/apache/conf/httpd.conf

	
以下の"赤字"の部分を書き換えて保存する。
  (注! 以下のhttpd.confの見本は、「とにかく何でも動く」設定で、セキュリティに関しては考慮
   していない。実際はcgiを許可するディレクトリなどは慎重にセキュリティポリシーを考える)

===========================================================
ServerType standalone
ServerRoot "/usr/local/apache"
PidFile /var/log/apache/httpd.pid
ScoreBoardFile /var/log/apache/httpd.scoreboard
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 15
MinSpareServers 5
MaxSpareServers 10
StartServers 5
MaxClients 150
MaxRequestsPerChild 0
ExtendedStatus On
Port 80
<IfDefine SSL>
Listen 80
Listen 443
</IfDefine>
User nobody
Group nobody
ServerAdmin you@domain.com
ServerName www.domain.com
DocumentRoot "/export/home/webmaster/htdocs"
<Directory />
    Options FollowSymLinks
    AllowOverride AuthConfig Limit
</Directory>
<Directory "/export/home/webmaster/htdocs">
    Options -Indexes FollowSymLinks MultiViews ExecCGI Includes
 AddHandler cgi-script .cgi
 AddHandler server-parsed .shtml
 AddType text/html .shtml
 AddType application/x-httpd-cgi .cgi
    AddType application/x-httpd-cgi .pl
    AllowOverride None
    Order allow,deny
 deny from 192.168.*
    Allow from all
</Directory>
<IfModule mod_userdir.c>
    UserDir public_html
</IfModule>
<Directory /export/home/*/public_html>
    Options -Indexes FollowSymLinks MultiViews ExecCGI Includes
        AddHandler cgi-script .cgi
        AddHandler server-parsed .shtml
 AddType text/html .shtml
        AddType application/x-httpd-cgi .cgi
    AddType application/x-httpd-cgi .pl
    Order allow,deny
    Allow from all
</Directory>
<IfModule mod_dir.c>
 DirectoryIndex index.html index.htm index.shtml index.cgi welcome.html welcome.htm
</IfModule>
AccessFileName .htaccess
<Files ~ "^\.ht">
    Order allow,deny
    Deny from all
</Files>
UseCanonicalName On
<IfModule mod_mime.c>
    TypesConfig /usr/local/apache/conf/mime.types
</IfModule>
DefaultType text/plain
<IfModule mod_mime_magic.c>
    MIMEMagicFile /usr/local/apache/conf/magic
</IfModule>
HostnameLookups On
ErrorLog /var/log/apache/error_log
LogLevel warn
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
CustomLog /var/log/apache/access_log "%h %l %u %t \"%r\" %s %b \"%{User-Agent}i\" %{Referer}i\""
ServerSignature On
<IfModule mod_alias.c>
    Alias /icons/ "/usr/local/apache/icons/"
    <Directory "/usr/local/apache/icons">
        Options -Indexes MultiViews
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>
#    Alias /manual/ "/usr/local/apache/htdocs/manual/"
#     <Directory "/usr/local/apache/htdocs/manual">
#         Options Indexes FollowSymlinks MultiViews
#         AllowOverride None
#         Order allow,deny
#          Allow from all
#     </Directory>
 ScriptAlias /cgi-bin/ "/export/home/webmaster/cgi-bin/"
 <Directory "/export/home/webmaster/cgi-bin">
        AllowOverride None
 Options -Indexes FollowSymLinks MultiViews ExecCGI Includes
        AddHandler cgi-script .cgi
        AddHandler server-parsed .shtml
        AddType application/x-httpd-cgi .cgi
        AddType application/x-httpd-cgi .pl
#       IndexOptions FancyIndexing
        Order allow,deny
        Allow from all
 </Directory>
</IfModule>
<IfModule mod_autoindex.c>
    AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip
    AddIconByType (TXT,/icons/text.gif) text/*
    AddIconByType (IMG,/icons/image2.gif) image/*
    AddIconByType (SND,/icons/sound2.gif) audio/*
    AddIconByType (VID,/icons/movie.gif) video/*
    AddIcon /icons/binary.gif .bin .exe
    AddIcon /icons/binhex.gif .hqx
    AddIcon /icons/tar.gif .tar
    AddIcon /icons/world2.gif .wrl .wrl.gz .vrml .vrm .iv
    AddIcon /icons/compressed.gif .Z .z .tgz .gz .zip
    AddIcon /icons/a.gif .ps .ai .eps
    AddIcon /icons/layout.gif .html .shtml .htm .pdf
    AddIcon /icons/text.gif .txt
    AddIcon /icons/c.gif .c
    AddIcon /icons/p.gif .pl .py
    AddIcon /icons/f.gif .for
    AddIcon /icons/dvi.gif .dvi
    AddIcon /icons/uuencoded.gif .uu
    AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl
    AddIcon /icons/tex.gif .tex
    AddIcon /icons/bomb.gif core
    AddIcon /icons/back.gif ..
    AddIcon /icons/hand.right.gif README
    AddIcon /icons/folder.gif ^^DIRECTORY^^
    AddIcon /icons/blank.gif ^^BLANKICON^^
    DefaultIcon /icons/unknown.gif
    ReadmeName README
    HeaderName HEADER
    IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t
</IfModule>
<IfModule mod_mime.c>
    AddEncoding x-compress Z
    AddEncoding x-gzip gz tgz
    AddLanguage da .dk
    AddLanguage nl .nl
    AddLanguage en .en
    AddLanguage et .ee
    AddLanguage fr .fr
    AddLanguage de .de
    AddLanguage el .el
    AddLanguage nn .nn
    AddLanguage he .he
    AddCharset ISO-8859-8 .iso8859-8
    AddLanguage it .it
    AddLanguage ja .ja
    AddCharset ISO-2022-JP .jis
    AddLanguage kr .kr
    AddCharset ISO-2022-KR .iso-kr
    AddLanguage no .no
    AddLanguage pl .po
    AddCharset ISO-8859-2 .iso-pl
    AddLanguage pt .pt
    AddLanguage pt-br .pt-br
    AddLanguage ltz .lu
    AddLanguage ca .ca
    AddLanguage es .es
    AddLanguage sv .se
    AddLanguage cz .cz
    AddLanguage ru .ru
    AddLanguage zh-tw .tw
    AddLanguage tw .tw
    AddCharset Big5         .Big5    .big5
    AddCharset WINDOWS-1251 .cp-1251
    AddCharset CP866        .cp866
    AddCharset ISO-8859-5   .iso-ru
    AddCharset KOI8-R       .koi8-r
    AddCharset UCS-2        .ucs2
    AddCharset UCS-4        .ucs4
    AddCharset UTF-8        .utf8
    <IfModule mod_negotiation.c>
        LanguagePriority en da nl et fr de el it ja kr no pl pt pt-br ru ltz ca es sv tw
    </IfModule>
    AddType application/x-tar .tgz
    AddHandler cgi-script .cgi
    AddHandler server-parsed .shtml
</IfModule>
<IfModule mod_setenvif.c>
    BrowserMatch "Mozilla/2" nokeepalive
    BrowserMatch "MSIE 4\.0b2;" nokeepalive downgrade-1.0 force-response-1.0
    BrowserMatch "RealPlayer 4\.0" force-response-1.0
    BrowserMatch "Java/1\.0" force-response-1.0
    BrowserMatch "JDK/1\.0" force-response-1.0
</IfModule>
<Location /server-status>
    SetHandler server-status
    Order deny,allow
    Deny from all
    Allow from Dell_2kp
</Location>
<Location /server-info>
    SetHandler server-info
    Order deny,allow
    Deny from all
    Allow from you'r_Windows
</Location>
<VirtualHost www.domain.com:80>
 SSLDisable
 Port 80
</VirtualHost>
<IfDefine SSL>
AddType application/x-x509-ca-cert .crt
AddType application/x-pkcs7-crl    .crl
</IfDefine>
<IfModule mod_ssl.c>
SSLPassPhraseDialog  builtin
SSLSessionCache         dbm:/var/log/apache/ssl_scache
SSLSessionCacheTimeout  300
SSLMutex  file:/var/log/apache/ssl_mutex
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
SSLLog      /var/log/apache/ssl_engine_log
SSLLogLevel info
</IfModule>
<IfDefine SSL>
<VirtualHost 192.168.0.150:443>
DocumentRoot "/export/home/webmaster/ssl_htdocs"
ServerName www.domain.com
ServerAdmin you@domain.com
ErrorLog /var/log/apache/error_log
CustomLog /var/log/apache/access_log "%h %l %u %t \"%r\" %s %b \"%{User-Agent}i\" %{Referer}i\""
SSLEngine on
SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
SSLCertificateFile /usr/local/ssl/certs/cert.pem
SSLCertificateKeyFile /usr/local/ssl/private/key2.pem
SSLVerifyClient 0
SSLVerifyDepth  10
<Files ~ "\.(cgi|shtml|phtml|php3?)$">
    SSLOptions +StdEnvVars
</Files>
<Directory "/usr/local/apache/cgi-bin">
    SSLOptions +StdEnvVars
</Directory>
<Directory "/export/home/webmaster/ssl_htdocs">
    Order allow,deny
    Allow from all
    AllowOverride AuthConfig Limit
    Options -Indexes FollowSymLinks MultiViews ExecCGI Includes
    AddHandler cgi-script .cgi
    AddHandler server-parsed .shtml
 AddType text/html .shtml
    AddType application/x-httpd-cgi .cgi
    AddType application/x-httpd-cgi .pl
    <Limit GET POST OPTIONS PROPFIND>
        Order allow,deny
        Allow from all
    </Limit>
    <LimitExcept GET POST OPTIONS PROPFIND>
        Order deny,allow
        Deny from all
    </LimitExcept>
</Directory>
<IfModule mod_userdir.c>
    UserDir ssl_public_html
</IfModule>
<Directory /export/home/*/ssl_public_html>
    Order allow,deny
    Allow from all
    AllowOverride AuthConfig Limit
    Options -Indexes FollowSymLinks MultiViews ExecCGI Includes
    AddHandler cgi-script .cgi
    AddHandler server-parsed .shtml
 AddType text/html .shtml
    AddType application/x-httpd-cgi .cgi
    AddType application/x-httpd-cgi .pl
    <Limit GET POST OPTIONS PROPFIND>
        Order allow,deny
        Allow from all
    </Limit>
    <LimitExcept GET POST OPTIONS PROPFIND>
        Order deny,allow
        Deny from all
    </LimitExcept>
</Directory>
<IfModule mod_mime.c>
    TypesConfig /usr/local/apache/conf/mime.types
</IfModule>
SetEnvIf User-Agent ".*MSIE.*" \
         nokeepalive ssl-unclean-shutdown \
         downgrade-1.0 force-response-1.0
CustomLog /var/log/apache/ssl_request_log \
          "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
</VirtualHost>                                  
</IfDefine>
===========================================================


httpd の起動

ログ用ディレクトリを作成しておく。
	# mkdir /var/log/apache

デフォルトのログファイルを作成したディレクトリにコピーしておく。
	# cp /usr/local/apache/logs/* /var/log/apache/

apacheの起動スクリプトを/etc/init.d/にコピーする。
	# cp /usr/local/apache/bin/apachectl /etc/init.d/httpd

コピーした起動スクリプトを編集する。
	# vi /etc/init.d/httpd

起動時にSSLも読み込むようにstartの部分を以下のように書き換えて保存する。
    start)
        if [ $RUNNING -eq 1 ]; then
            echo "$0 $ARG: httpd (pid $PID) already running"
            continue
        fi
        if $HTTPD -DSSL; then
            echo "$0 $ARG: httpd started"
        else
            echo "$0 $ARG: httpd could not be started"
            ERROR=3
        fi
        ;;

ディレクトリを移動する。
	# cd /etc/rc2.d/

起動スクリプトのシンボリックリンクを張る。
	# ln -s ../init.d/httpd ./S78httpd

起動させる。
	# /etc/rc2.d/S78httpd start
	# exit