マソム自宅サーバ構築の記録

  • Apache2.2とSSLをソースからインストール
  • 作成日:08/02/22    更新日:09/08/07

前置き

Fedora 7 にApache2.2をソースからインストールします。 SELinuxを有効にしてFedora 7をインストールしましたが、そこにソースからサービスをインストールしたことがまだありません。比較的慣れているApacheで試してみたいと思います。(結果、Apacheのインストールは無事に済みましたが、PHPのインストールでSELinuxに引っ掛かりました。)
バージョンは2008年2月現在で最新のhttpd-2.2.8とし、SSLを使えるようにします。各モジュールはDSOとして使われるようにします。

準備

インストールした覚えは無いのにRPMパッケージで入っていました。反省。
確認して削除します。
# rpm -q httpd
httpd-2.2.4-4.1.fc7
# rpm -e httpd
エラー: 依存性の欠如: httpd は (インストール済み)BackupPC-2.1.2-7.fc6.noarch に必要とされています
BackupPCはサーバのアックアップに便利なデーモンのようですが、起動はしていません。
# /sbin/chkconfig --list BackupPC
BackupPC 0:off 1:off 2:off 3:off 4:off 5:off 6:off
依存関係を調べてみました。
# rpm -qR BackupPC
/bin/sh
/bin/sh
/bin/sh
/bin/sh
/bin/sh
/sbin/chkconfig
/sbin/chkconfig
/sbin/service
/sbin/service
/sbin/service
/usr/bin/perl
/usr/sbin/useradd
/usr/sbin/usermod
config(BackupPC) = 2.1.2-7.fc6
httpd
perl(Archive::Zip)
perl(BackupPC::Attrib)
perl(BackupPC::CGI::Lib)
perl(BackupPC::FileZIO)
perl(BackupPC::Lib)
perl(BackupPC::PoolWrite)
perl(BackupPC::View)
perl(BackupPC::Xfer::Archive)
perl(BackupPC::Xfer::Rsync)
perl(BackupPC::Xfer::RsyncDigest)
perl(BackupPC::Xfer::RsyncFileIO)
perl(BackupPC::Xfer::Smb)
perl(BackupPC::Xfer::Tar)
perl(BackupPC::Zip::FileMember)
perl(CGI)
perl(CGI::Carp)
perl(Carp)
perl(Compress::Zlib)
perl(Config)
perl(Cwd)
perl(Data::Dumper)
perl(Digest::MD5)
perl(DirHandle)
perl(Exporter)
perl(Fcntl)
perl(File::Compare)
perl(File::Copy)
perl(File::Find)
perl(File::Path)
perl(File::RsyncP)
perl(Getopt::Std)
perl(IO::Handle)
perl(POSIX)
perl(Socket)
perl(constant)
perl(lib)
perl(strict)
perl(vars)
perl-suidperl
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rsync
BackupPCは使っていませんので、取り合えず依存関係を無視して、削除してしまいました。
# rpm -e --nodeps httpd
今までのユーザも削除しておきます。
注)もし同じ状況の場合は、削除しない方が良いかもしれません。理由は、
 1. UIDを500番以下にしたい。POPサーバDovecotの有効なUIDが500番以上となっているので。
 2. backuppcグループにがapacheユーザが所属している。
 為です。
# /usr/sbin/userdel apache

openSSLのインストール

openssl-0.9.8b-12.fc7がFedora 7のRPMパッケージでインストールされているので、それをそのまま使うことにしました。
ディレクトリは/etc/pki/tls/となっているようです。 環境によって/usr/share/ssl/等のように違いますので読み替えて下さい。

Apacheのインストール

まず、httpdをミラーサイトからダウンロード 。
私はユーザディレクトリにソース置き場を作ってあるので、そこに移動してからダウンロードします。 勿論/usr/local/srcでも良いと思います。
$ cd /home/ユーザ名/src
$ wget http://www.meisei-u.ac.jp/mirror/apache/httpd/httpd-2.2.8.tar.gz
ソースを展開します。
$ tar xzf httpd-2.2.8.tar.gz
ソースディレクトリに移動します。
$ cd httpd-2.2.8
まず、コンパイルオプション等をヘルプで確認しました。
$ ./configure -help > help.txt
$ vi help.txt
  ・・・省略・・・
Optional Features:
  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
  --enable-layout=LAYOUT
  --enable-v4-mapped      Allow IPv6 sockets to handle IPv4 connections
  --enable-exception-hook Enable fatal exception hook
  --enable-maintainer-mode
                          Turn on debugging and compile time warnings
  --enable-pie            Build httpd as a Position Independent Executable
  --enable-modules=MODULE-LIST
                          Space-separated list of modules to enable | "all" |
                          "most"
  --enable-mods-shared=MODULE-LIST
                          Space-separated list of shared modules to enable |
                          "all" | "most"
  --disable-authn-file    file-based authentication control
  --enable-authn-dbm      DBM-based authentication control
  --enable-authn-anon     anonymous user authentication control
  --enable-authn-dbd      SQL-based authentication control
  --disable-authn-default authentication backstopper
  --enable-authn-alias    auth provider alias
  --disable-authz-host    host-based authorization control
  --disable-authz-groupfile
                          'require group' authorization control
  --disable-authz-user    'require user' authorization control
  --enable-authz-dbm      DBM-based authorization control
  --enable-authz-owner    'require file-owner' authorization control
  --enable-authnz-ldap    LDAP based authentication
  --disable-authz-default authorization control backstopper
  --disable-auth-basic    basic authentication
  --enable-auth-digest    RFC2617 Digest authentication
  --enable-isapi          isapi extension support
  --enable-file-cache     File cache
  --enable-cache          dynamic file caching
  --enable-disk-cache     disk caching module
  --enable-mem-cache      memory caching module
  --enable-dbd            Apache DBD Framework
  --enable-bucketeer      buckets manipulation filter
  --enable-dumpio         I/O dump filter
  --enable-echo           ECHO server
  --enable-example        example and demo module
  --enable-case-filter    example uppercase conversion filter
  --enable-case-filter-in example uppercase conversion input filter
  --enable-ext-filter     external filter module
  --disable-include       Server Side Includes
  --disable-filter        Smart Filtering
  --enable-substitute     response content rewrite-like filtering
  --disable-charset-lite  character set translation
  --enable-charset-lite   character set translation
  --enable-deflate        Deflate transfer encoding support
  --enable-ldap           LDAP caching and connection pooling services
  --disable-log-config    logging configuration
  --enable-log-forensic   forensic logging
  --enable-logio          input and output logging
  --disable-env           clearing/setting of ENV vars
  --enable-mime-magic     automagically determining MIME type
  --enable-cern-meta      CERN-type meta files
  --enable-expires        Expires header control
  --enable-headers        HTTP header control
  --enable-ident          RFC 1413 identity check
  --enable-usertrack      user-session tracking
  --enable-unique-id      per-request unique ids
  --disable-setenvif      basing ENV vars on headers
  --enable-version        determining httpd version in config files
  --enable-proxy          Apache proxy module
  --enable-proxy-connect  Apache proxy CONNECT module
  --enable-proxy-ftp      Apache proxy FTP module
  --enable-proxy-http     Apache proxy HTTP module
  --enable-proxy-ajp      Apache proxy AJP module
  --enable-proxy-balancer Apache proxy BALANCER module
  --enable-ssl            SSL/TLS support (mod_ssl)
  --enable-distcache      Select distcache support in mod_ssl
  --enable-optional-hook-export
                          example optional hook exporter
  --enable-optional-hook-import
                          example optional hook importer
  --enable-optional-fn-import
                          example optional function importer
  --enable-optional-fn-export
                          example optional function exporter
  --enable-static-support Build a statically linked version of the support
                          binaries
  --enable-static-htpasswd
                          Build a statically linked version of htpasswd
  --enable-static-htdigest
                          Build a statically linked version of htdigest
  --enable-static-rotatelogs
                          Build a statically linked version of rotatelogs
  --enable-static-logresolve
                          Build a statically linked version of logresolve
  --enable-static-htdbm   Build a statically linked version of htdbm
  --enable-static-ab      Build a statically linked version of ab
  --enable-static-checkgid
                          Build a statically linked version of checkgid
  --enable-static-htcacheclean
                          Build a statically linked version of htcacheclean
  --enable-static-httxt2dbm
                          Build a statically linked version of httxt2dbm
  --enable-http           HTTP protocol handling
  --disable-mime          mapping of file-extension to MIME
  --enable-dav            WebDAV protocol handling
  --disable-status        process/thread monitoring
  --disable-autoindex     directory listing
  --disable-asis          as-is filetypes
  --enable-info           server information
  --enable-suexec         set uid and gid for spawned processes
  --disable-cgid          CGI scripts
  --enable-cgi            CGI scripts
  --disable-cgi           CGI scripts
  --enable-cgid           CGI scripts
  --enable-dav-fs         DAV provider for the filesystem
  --enable-dav-lock       DAV provider for generic locking
  --enable-vhost-alias    mass virtual hosting module
  --disable-negotiation   content negotiation
  --disable-dir           directory request handling
  --enable-imagemap       server-side imagemaps
  --disable-actions       Action triggering on requests
  --enable-speling        correct common URL misspellings
  --disable-userdir       mapping of requests to user-specific directories
  --disable-alias         mapping of requests to different filesystem parts
  --enable-rewrite        rule based URL manipulation
  --enable-so             DSO capability

Optional Packages:
  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
  --with-included-apr     Use bundled copies of APR/APR-Util
  --with-apr=PATH         prefix for installed APR, path to APR build tree,
                          or the full path to apr-config
  --with-apr-util=PATH    prefix for installed APU, path to APU build tree,
                          or the full path to apu-config
  --with-pcre=PATH        Use external PCRE library
  --with-port=PORT        Port on which to listen (default is 80)
  --with-z=DIR            use a specific zlib library
  --with-sslc=DIR         RSA SSL-C SSL/TLS toolkit
  --with-ssl=DIR          OpenSSL SSL/TLS toolkit
  --with-mpm=MPM          Choose the process model for Apache to use.
                          MPM={beos|event|worker|prefork|mpmt_os2}
  --with-module=module-type:module-file
                          Enable module-file in the modules/<module-type>
                          directory.
  --with-program-name     alternate executable name
  --with-suexec-bin       Path to suexec binary
  --with-suexec-caller    User allowed to call SuExec
  --with-suexec-userdir   User subdirectory
  --with-suexec-docroot   SuExec root directory
  --with-suexec-uidmin    Minimal allowed UID
  --with-suexec-gidmin    Minimal allowed GID
  --with-suexec-logfile   Set the logfile
  --with-suexec-safepath  Set the safepath
  --with-suexec-umask     umask for suexec'd process

Some influential environment variables:
CC C compiler command
CFLAGS C compiler flags
LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
nonstandard directory <lib dir>
CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I<include dir> if
you have headers in a nonstandard directory <include dir>
CPP C preprocessor

Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
コンパイルします。
./configureのオプション--enable-modulesはmod_so, mos_sslを追加、--enable-mods-sharedはmod_sslとデフォルトで入るモジュールが全てDSOになる設定です。 デフォルトのモジュールを全て使う予定は無いのですが、今後の検証や開発で困らないようにインストールだけはしておき、当座使わないものは設定ファイルでコメントアウトします。
$ cd httpd-2.2.8
$ ./configure --enable-modules='so ssl' \
              --enable-mods-shared='ssl authn_file authn_default authz_host authz_groupfile authz_user \
                    authz_default auth_basic include filter log_config env setenvif mime \
                    status autoindex asis cgi negotiation dir actions userdir alias' \
              2>&1 |tee configure.log
$ make 2>&1 |tee make.log
インストールします。
$ su
# make install 2>&1 |tee install.log
/usr/local/apache2/にインストールされました。
Apacheを実行するユーザを作成しておきます。 UIDは他のユーザと重複しないようにします。
# /usr/sbin/groupadd -g 48 apache
# /usr/sbin/useradd -g apache -u 48 -d /usr/local/apache2 -s /sbin/nologin apache
Creating mailbox file: ファイルが存在します
useradd: warning: the home directory already exists.
Not copying any file from skel directory into it.
BackupPCとの関係を戻しておきます。 BackupPCの問題と関係ない場合は作業は要りません。
# /usr/sbin/usermod -G backuppc apache
次に 設定ファイルhttpd.confを編集します。
# vi /usr/local/apache2/conf/httpd.conf
以下は編集するディレクティブです。

使わないモジュールをコメントアウトします。しかし、サーバによって必要なモジュールは違うと思いますので、それぞれの環境での検討が必要です。取り合えずWebサーバを立ててみたいだけならコメントアウトの必要はありません。
mod_include:SSIを提供するモジュール
mod_status:サーバの統計情報のページが表示可能になるモジュール
mod_asis:指定した拡張子のファイルを殆どそのまま送信する機能のモジュール
mod_negotiation:コンテントネゴシエーション(それなりのファイルタイプを選択する)機能のモジュール
mod_imap:サーバーサイド イメージマップのモジュール <-デフォルトでインストールされなくなりました。
mod_actions:Actionディレクティブなどで指定した拡張子やコンテントタイプに対して指定したCGIを実行するようにするモジュール
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authn_default_module modules/mod_authn_default.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule authz_default_module modules/mod_authz_default.so
LoadModule auth_basic_module modules/mod_auth_basic.so
##LoadModule include_module modules/mod_include.so
LoadModule filter_module modules/mod_filter.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule env_module modules/mod_env.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule ssl_module modules/mod_ssl.so
LoadModule mime_module modules/mod_mime.so
##LoadModule status_module modules/mod_status.so
LoadModule autoindex_module modules/mod_autoindex.so
##LoadModule asis_module modules/mod_asis.so
LoadModule cgi_module modules/mod_cgi.so
##LoadModule negotiation_module modules/mod_negotiation.so
LoadModule dir_module modules/mod_dir.so
##LoadModule actions_module modules/mod_actions.so
LoadModule userdir_module modules/mod_userdir.so
LoadModule alias_module modules/mod_alias.so
ユーザとグループを変更します。
##User daemon
##Group daemon
User apache
Group apache
ServerAdmin:管理者のメールアドレスを指定します。
##ServerAdmin you@example.com
ServerAdmin 管理者のメールアドレス
ServerName:wwwサーバのFQDNとポート番号を指定します。 リダイレクションURLを作成する時に使われます。DNSのAliasでwwwサーバ名を指定している場合でも実名ではなく、ここで指定したホスト名が使われます。 なお、バージョン1.3のportディレクティブを兼ねています。
ServerName xxxxx.xxxxxx.xxx:80
DocumentRoot:ドキュメントルートにしたいディレクトリを変更したい場合指定します。
##DocumentRoot "/usr/local/apache2/htdocs" DocumentRoot "ドキュメントルートにしたいディレクトリパス"
<Directory />:全てのディレクトリのデフォルト状態を指定します。
セキュリティの為に全てのアクセスを禁止にしようと思ったら、httpd-2.2.8では既にそうなっていました。
<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
</Directory>
<Directory "ドキュメントルートのディレクトリ">: ドキュメントルートのディレクトリの状態を設定します。 DocumentRootディレクティブにディレクトリ名を合わせます。
OptionsのIndexesを削除してディレクトリ一覧の表示を禁止します。 シンボリックリンクを辿ることは許可したままにします。 私は、コンテントネゴシエーションする必要がないのでOptionsにMultiViewsを設定しません。
なお、AllowOverride Noneで.htaccessファイルがあっても読み込みません。
Allow from allで全てのアクセスを許可します。
##<Directory "/usr/local/apache2/htdocs">
<Directory "ドキュメントルートにしたいディレクトリパス">
## Options Indexes FollowSymLinks
    Options FollowSymLinks
    AllowOverride None
    Order Deny,Allow
    Allow from all
</Directory>
URLが / で終わるアクセスの時に表示させるファイル名を指定します。
PHPを使うので、その拡張子がついたファイル名も指定しておきます。
<IfModule dir_module>
DirectoryIndex index.html index.htm index.php
</IfModule>
必要ならエイリアスの定義場所で、エイリアスとして参照したいディレクトリを設定します。
<IfModule alias_module>
    ・・・省略・・・
    Alias /エイリアス名 "実際のディレクトリパス"

<Directory "実際のディレクトリパス">
  Options FollowSymLinks
  AllowOverride None
  Order deny,allow
  Allow from all
</Directory>

</IfModule>
ScriptAlias:私はCGIを(このディレクトリでは)使いませんのでコメントアウトします。
<IfModule alias_module>
    ・・・省略・・・
##ScriptAlias /cgi-bin/ "/usr/local/apache2/cgi-bin/"

</IfModule>
    ・・・省略・・・
##<Directory "/usr/local/apache2/cgi-bin">
##    AllowOverride None
##    Options None
##    Order allow,deny
##    Allow from all
##</Directory>
httpd-2.2.8では、設定ファイルが細かく分かれていました。設定を変更するファイルを読み込むようにコメントを外します。
# Supplemental configuration
#
# The configuration files in the conf/extra/ directory can be
# included to add extra features or to modify the default configuration of
# the server, or you may simply copy their contents here and change as
# necessary.

# Server-pool management (MPM specific)
#Include conf/extra/httpd-mpm.conf

# Multi-language error messages
#Include conf/extra/httpd-multilang-errordoc.conf

# Fancy directory listings
#Include conf/extra/httpd-autoindex.conf

# Language settings
#Include conf/extra/httpd-languages.conf

# User home directories
#Include conf/extra/httpd-userdir.conf
Include conf/extra/httpd-userdir.conf

# Real-time info on requests and configuration
#Include conf/extra/httpd-info.conf

# Virtual hosts
#Include conf/extra/httpd-vhosts.conf

# Local access to the Apache HTTP Server Manual
#Include conf/extra/httpd-manual.conf

# Distributed authoring and versioning (WebDAV)
#Include conf/extra/httpd-dav.conf

# Various default settings
#Include conf/extra/httpd-default.conf
Include conf/extra/httpd-default.conf

# Secure (SSL/TLS) connections
#Include conf/extra/httpd-ssl.conf
Include conf/extra/httpd-ssl.conf
httpd.confを保存します。

変更したいその他の設定ファイルを編集します。

UserDir:ユーザ専用ディレクトリの位置。私はユーザ名とディレクトリ名を別にしているので使いません。禁止します。
# vi /usr/local/apache2/conf/extra/httpd-userdir.conf
    ・・・省略・・・
##UserDir public_html
UserDir disabled
    ・・・省略・・・

ServerTokens:セキュリティを考え応答ヘッダの内容を制限します。 Majorなら応答を"Apache"とメジャーバージョン番号に制限。Prodなら"Apache"のみになります。
ServerSignature:Apacheが生成したエラーメッセージなどのフッターの表示状態を設定します。 OnだとServerNameとServerTokensで設定した情報が表示されます。私はOffにして表示しないようにします。
# vi /usr/local/apache2/conf/extra/httpd-default.conf
    ・・・省略・・・
##ServerTokens Full
ServerTokens Major
    ・・・省略・・・
##ServerSignature On
ServerSignature Off
    ・・・省略・・・

次に自動起動の設定をします。
簡単な方法として、 以下のように/etc/rc.d/rc.localに起動スクリプトを追加してもOKですが、
# vi /etc/rc.d/rc.local /usr/local/apache2/bin/apachectl start
折角なのでrcスクリプトとして登録します。

起動スクリプトを/etc/rc.d/init.dにコピーして、各rc.dにシンボリックリンクを作成します。
# cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd
# ln -s ../init.d/httpd /etc/rc.d/rc0.d/K15httpd
# ln -s ../init.d/httpd /etc/rc.d/rc1.d/K15httpd
# ln -s ../init.d/httpd /etc/rc.d/rc2.d/K15httpd
# ln -s ../init.d/httpd /etc/rc.d/rc3.d/S85httpd
# ln -s ../init.d/httpd /etc/rc.d/rc4.d/S85httpd
# ln -s ../init.d/httpd /etc/rc.d/rc5.d/S85httpd
# ln -s ../init.d/httpd /etc/rc.d/rc6.d/K15httpd

Apacheの起動テスト

Apacheを起動します。なお、SSLの設定が済んでいないので、こんなメッセージが出ました。
# /usr/local/apache2/bin/apachectl start
無事LAN内のWindowsマシンのブラウザからホームページを見ることが出来ました。
マシンを再起動しApacheが自動起動していることも確認します。

サーバ証明書の作成

さて、Apacheは起動できるようになりましたが、まだSSLは使えません。まず認証に必要なサーバ鍵とサーバ証明書を作成します。

SSLの設定

SSLの設定を行います。
ここではサイト全体を通常の状態(暗号化なし)とSSLを使った状態(暗号化あり)の両方でアクセス出来るようにします。
まず、 設定ファイルssl.confを編集します。
# vi /usr/local/apache2/conf/extra/httpd-ssl.conf
以下は編集するディレクティブです。
作成したサーバ鍵とサーバ証明書のパスもセットします。
<VirtualHost _default_:443>

#   General setup for the virtual host
##DocumentRoot "/usr/local/apache2/htdocs"
##ServerName www.example.com:443
##ServerAdmin you@example.com
ErrorLog /usr/local/apache2/logs/error_log
TransferLog /usr/local/apache2/logs/access_log

SSLEngine on

##SSLCertificateFile "/usr/local/apache2/conf/server.crt"
#SSLCertificateFile "/usr/local/apache2/conf/server-dsa.crt"
SSLCertificateFile "/etc/pki/tls/certs/www.mathomfactory.com.crt"

##SSLCertificateKeyFile "/usr/local/apache2/conf/server.key"
#SSLCertificateKeyFile "/usr/local/apache2/conf/server-dsa.key"
SSLCertificateKeyFile "/etc/pki/tls/private/www.mathomfactory.com_nopswd.key"

##<Directory "/usr/local/apache2/cgi-bin">
## SSLOptions +StdEnvVars
##</Directory>
以前はSSLありでApacheを起動する時にはstartsslとする必要がありましたが、start又はrestartでOKになりました。
# /usr/local/apache2/bin/apachectl restart

SSLの設定-その2

今度は、通常の状態(暗号化なし)とSSLを使った状態(暗号化あり)でディレクトリを分けた設定にしてみます。
<VirtualHost _default_:443>

<Directory "/home/mathom/ssl">
    AllowOverride FileInfo AuthConfig Limit
    Options SymLinksIfOwnerMatch
    Order allow,deny
    Allow from all
</Directory>

#   General setup for the virtual host
##DocumentRoot "/usr/local/apache2/htdocs"
##ServerName www.example.com:443
##ServerAdmin you@example.com
DocumentRoot "SSLのドキュメントルートにしたいディレクトリパス"
ServerName www.mathomfactory.com:443
ServerAdmin 管理者のメールアドレス

ErrorLog /usr/local/apache2/logs/ssl_error_log
TransferLog /usr/local/apache2/logs/ssl_access_log

SSLEngine on

##SSLCertificateFile "/usr/local/apache2/conf/server.crt"
#SSLCertificateFile "/usr/local/apache2/conf/server-dsa.crt"
SSLCertificateFile "/etc/pki/tls/certs/www.mathomfactory.com.crt"

##SSLCertificateKeyFile "/usr/local/apache2/conf/server.key"
#SSLCertificateKeyFile "/usr/local/apache2/conf/server-dsa.key"
SSLCertificateKeyFile "/etc/pki/tls/private/www.mathomfactory.com_nopswd.key"

##<Directory "/usr/local/apache2/cgi-bin">
## SSLOptions +StdEnvVars
##</Directory>

紆余曲折Tips

openSSLのソースからのインストール

折角調べたので、ソースからのインストール方法も載せておきます。
まず、openSSLをダウンロード。http://www.openssl.org/で最新版は確認できます。
$ wget http://www.openssl.org/source/openssl-x.x.x.tar.gz
ソースを展開します。
$ tar xzf openssl-x.x.x.tar.gz
ソースディレクトリに移動しコンパイルします。
$ cd openssl-x.x.x
$ ./configure linux-elf
$ make
$ make test
インストールします。
$ su
# make install

デフォルトで入るモジュールの確認

やり方は他にも有ると思いますが、私はオプションを付けずに./configureをしてメッセージのログを確認しました。デフォルトで入るモジュールには"(default)"と付いています。config.logでも確認できます。
$ ./configure 2>&1 |tee configure.log
$ vi configure.log
    ...省略...
checking whether to enable mod_authn_file... yes (default)
checking whether to enable mod_authn_dbm... no
checking whether to enable mod_authn_anon... no
checking whether to enable mod_authn_dbd... no
checking whether to enable mod_authn_default... yes (default)
checking whether to enable mod_authn_alias... no
checking whether to enable mod_authz_host... yes (default)
checking whether to enable mod_authz_groupfile... yes (default)
checking whether to enable mod_authz_user... yes (default)
checking whether to enable mod_authz_dbm... no
checking whether to enable mod_authz_owner... no
checking whether to enable mod_authnz_ldap... no
checking whether to enable mod_authz_default... yes (default)
checking whether to enable mod_auth_basic... yes (default)
checking whether to enable mod_auth_digest... no
checking whether to enable mod_isapi... no
checking whether to enable mod_file_cache... no
checking whether to enable mod_cache... no
checking whether to enable mod_disk_cache... no
checking whether to enable mod_mem_cache... no
checking whether to enable mod_dbd... no
checking whether to enable mod_bucketeer... no
checking whether to enable mod_dumpio... no
checking whether to enable mod_echo... no
checking whether to enable mod_example... no
checking whether to enable mod_case_filter... no
checking whether to enable mod_case_filter_in... no
checking whether to enable mod_ext_filter... no
checking whether to enable mod_include... yes (default)
checking whether to enable mod_filter... yes (default)
checking whether to enable mod_substitute... no
checking whether to enable mod_charset_lite... no
checking whether to enable mod_deflate... no
checking whether to enable mod_ldap... no
checking whether to enable mod_log_config... yes (default)
checking whether to enable mod_log_forensic... no
checking whether to enable mod_logio... no
checking whether to enable mod_env... yes (default)
checking whether to enable mod_mime_magic... no
checking whether to enable mod_cern_meta... no
checking whether to enable mod_expires... no
checking whether to enable mod_headers... no
checking whether to enable mod_ident... no
checking whether to enable mod_usertrack... no
checking whether to enable mod_unique_id... no
checking whether to enable mod_setenvif... yes (default)
checking whether to enable mod_version... no
checking whether to enable mod_proxy... no
checking whether to enable mod_proxy_connect... no
checking whether to enable mod_proxy_ftp... no
checking whether to enable mod_proxy_http... no
checking whether to enable mod_proxy_ajp... no
checking whether to enable mod_proxy_balancer... no
  adding "-I$(top_srcdir)/modules/proxy/../generators" to INCLUDES
checking whether to enable mod_ssl... no
  adding "-I$(top_srcdir)/modules/ssl" to INCLUDES
checking whether to enable mod_optional_hook_export... no
checking whether to enable mod_optional_hook_import... no
checking whether to enable mod_optional_fn_import... no
checking whether to enable mod_optional_fn_export... no
    ...省略...
checking whether to enable mod_http... yes
checking whether to enable mod_mime... yes (default)
checking for extra modules... none
checking whether to enable mod_dav... no
  adding "-I$(top_srcdir)/modules/dav/main" to INCLUDES
checking whether to enable mod_status... yes (default)
checking whether to enable mod_autoindex... yes (default)
checking whether to enable mod_asis... yes (default)
checking whether to enable mod_info... no
checking whether to enable mod_suexec... no
checking whether to enable mod_cgi... yes (default)
checking whether to enable mod_cgid... no
checking whether to enable mod_dav_fs... no
checking whether to enable mod_dav_lock... no
checking whether to enable mod_vhost_alias... no
checking whether to enable mod_negotiation... yes (default)
checking whether to enable mod_dir... yes (default)
checking whether to enable mod_imagemap... no
checking whether to enable mod_actions... yes (default)
checking whether to enable mod_speling... no
checking whether to enable mod_userdir... yes (default)
checking whether to enable mod_alias... yes (default)
checking whether to enable mod_rewrite... no
  setting HTTPD_LDFLAGS to "-export-dynamic"
checking whether to enable mod_so... yes
checking whether to enable mod_speling... no
checking whether to enable mod_userdir... yes (default)
checking whether to enable mod_alias... yes (default)
checking whether to enable mod_rewrite... no
  setting HTTPD_LDFLAGS to "-export-dynamic"
checking whether to enable mod_so... yes
    ...省略...

httpdの起動エラー

# /usr/local/apache2/bin/apachectl start
# tail /usr/local/apache2/logs/error_log
[Mon Feb 25 20:38:07 2008] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
mod_sslを組み込んでおきながら設定ファイルをSSL用に変更していないと上のエラーが出るようです。

組み込まれているモジュールの確認

# /usr/local/apache2/bin/httpd -l
Compiled in modules:
  core.c
  prefork.c
  http_core.c
  mod_so.c