■インストールファイルはここ
Apache
http://www.apache.org/dist/httpd/
日本語解説サイト
http://www.apache.jp/docs/
OpenSSL / mod_ssl
ftp://ftp.infoscience.co.jp/pub/Crypto/SSL/
日本語解説サイト
http://japache.infoscience.co.jp/Apache-SSL/
PHP
http://www.php.net/downloads.php
■tar xvzf apache.tar.gz で解凍する
こんな感じのファイルが出来上がる。
ABOUT_APACHE LICENSE README-WIN.TXT cgi-bin configure logs
Announcement Makefile.tmpl README.configure conf htdocs src
INSTALL README WARNING-WIN.TXT config.layout icons
■./configure
・どこにインストールされるのか心配だったらこのように試してみるとよい。
ちなみにlayoutファイルはconfig.layout
# ./configure --with-layout=RedHat --show-layout
・su_execをサポートする
http://www.apache.jp/docs/suexec.html
これも上記の方法でインストールディレクトリを確認できる
# ./configure --with-layout=RedHat --show-layout \ "--enable-suexec" \ "--suexec-caller=apache" \ "--suexec-docroot=/var/www/html" \ "--suexec-logfile=/var/log/httpd/suexec_log" \ "--suexec-uidmin=500" \ "--suexec-gidmin=500"
・DSOモジュールなどを組み込む
http://www.apache.jp/docs/mod/index-bytype.html
"--enable-module=so" \ // これは必ず入れておく
"--enable-rule=SHARED_CORE" \ // ちょっとこれが意味不明だけど必要
"--enable-module=info" \ // サーバの設定情報
"--enable-module=status" \ // サーバーのステータス
"--enable-module=rewrite" \ // 正規表現のURIからファイル名のマッピング機能
■ ./configure のオプション
--quiet 画面上にメッセージを表示しない
--silent quietと同じ
--verbose 画面上に詳細なメッセージを表示
--shadow[=DIR] コンパイルに必要なファイルを指定したディレクトリ以下に作成
--help 画面上にヘルプを表示
--show-layout 画面上にApacheがインストールされるディレクトリを表示
--with-layout=[F:]ID 指定したファイルの内容のとおりにApacheのファイルを配置する
--target=TARGET 設定ファイルなどの名前を変更(httpd.conf→ichishi.confなど)
--prefix=PREFIX Apacheがインストールされるディレクトリを変更する
--exec-prefix=EPREFIX ファイルの種類別にディレクトリを指定する。変更後、どこにインストールされるかはshow-layoutで確認
--bindir=DIR
--sbindir=DIR
--libexecdir=DIR
--mandir=DIR
--sysconfdir=DIR
--datadir=DIR
--iconsdir=DIR
--htdocsdir=DIR
--cgidir=DIR
--includedir=DIR
--localstatedir=DIR
--runtimedir=DIR
--logfiledir=DIR
--proxycachedir=DIR
--add-module=FILE Apacheの標準以外のモジュールファイルを追加する
--activate-module=FILE
--permute-module=N1:N2 モジュールを組み込む順序を指定する
--enable-module=NAME 指定したApacheの標準付属モジュールを組み込む
--disable-module=NAME 指定したApacheの標準付属モジュールを組み込まない
--enable-shared=NAME 指定したApacheの標準付属モジュールをDSO(補足3)で組み込む
--disable-shared=NAME 指定したApacheの標準付属モジュールをDSOで組み込まない
■
モジュール 機能 デフォルト
mod_access ホストに基づいたアクセス制御 Yes
mod_actions ファイル種別/メソッドに基づいたスクリプトの実行 Yes
mod_alias Aliases and redirects. Yes
mod_asis .asis ファイルハンドラー Yes
mod_auth テキストファイルを用いたユーザ認証 Yes
mod_auth_anon FTPスタイルの匿名(Anonymous)ユーザー認証 No
mod_auth_db バークレイDBファイルを用いたユーザー認証 No
mod_auth_dbm DBMファイルを用いたユーザー認証 No
mod_autoindex 自動ディレクトリリスト表示 Yes
mod_cern_meta HTTPハンドラメタファイルのサポート No
mod_cgi CGIスクリプトの実行 Yes
mod_digest MD5ユーザー認証 No
mod_dir 基本的なディレクトリハンドリング Yes
mod_env CGIスクリプトへの環境変数の継承 Yes
mod_example Apache APIの実証 No
mod_expires 割り当ての終了:リソースへのヘッダ No
mod_headers リソースに任意のHTTPヘッダを加える No
mod_imap イメージマップファイルのハンドラ Yes
mod_include サーバで解析するドキュメント Yes
mod_info サーバの設定情報 No
mod_log_agent ユーザーエージェントのログ蓄積 No
mod_log_config ユーザー定義ログ Yes
mod_log_referer ドキュメントリファレンスのログ蓄積 No
mod_mime ファイル拡張子を使ったドキュメントタイプの決定 Yes
mod_mime-magic magic numbers を使ったドキュメントタイプの決定 No
mod_negotiation コンテンツのネゴシエーション Yes
mod_proxy キャッシングプロキシ機能 No
mod_rewrite 通常表記を使った強力なURI-to-filenameマッピング No
mod_setenvif クライアント情報を基にした環境変数の設定 Yes
mod_spelling URLでのminor typosの自動訂正 No
mod_status サーバステータスを表示 Yes
mod_unique-id あらゆるリクエストのためのユニークなリクエスト識別の生成 No
mod_userdir ユーザーのホーム・ディレクトリ Yes
mod_usertrack cookieを用いたユーザー追跡(mod_cookies.cと置き換え) No
■結果、これでconfigureをやってみる
# ./configure --with-layout=RedHat \
"--enable-suexec" \
"--suexec-caller=apache" \
"--suexec-docroot=/var/www/html" \
"--suexec-logfile=/var/log/httpd/suexec_log" \
"--suexec-uidmin=500" \
"--suexec-gidmin=500" \
"--enable-module=so" \
"--enable-rule=SHARED_CORE" \
"--enable-module=info" \
"--enable-module=status" \
"--enable-module=rewrite"
config.statusファイルとMakefile が出来上がるので
# make
# make install
+--------------------------------------------------------+
| You now have successfully built and installed the | Apache 1.3 HTTP
| server. To verify that Apache actually | works correctly you now
| should first check the | (initially created or preserved)
| configuration files |
| |
| /etc/httpd/conf/httpd.conf
| |
| and then you should be able to immediately fire up | Apache the first
| time by running: |
| |
| /usr/sbin/apachectl start
| |
| Thanks for using Apache. The Apache Group | http://www.apache.org/ |
+--------------------------------------------------------+
これでインストールが完了する。
■起動スクリプトの作成
通常、rpmでインストールすると、/etc/rc.d/init.d/にhttpdという
スクリプトが出来るので同様に作ってやればよい。
これを /etc/rc.d/rc3.d/S85httpd にシンボリックリンクを作る。
# ln -s /etc/rc.d/init.d/httpd /etc/rc.d/rc3.d/S85httpd
chkconfig --add httpd でもいいのか?
#!/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/access.conf
# config: /etc/httpd/conf/httpd.conf
# config: /etc/httpd/conf/srm.conf
# Source function library.
. /etc/rc.d/init.d/functions
# This will prevent initlog from swallowing up a pass-phrase prompt if # mod_ssl needs a pass-phrase from the user.
INITLOG_ARGS=""
# Path to the apachectl script, server binary, and short-form for messages.
apachectl=/usr/sbin/apachectl
httpd=/usr/sbin/httpd
prog=httpd
RETVAL=0
# Find the installed modules and convert their names into arguments httpd # can use.
moduleargs() {
moduledir=/usr/lib/apache
moduleargs=`
/usr/bin/find ${moduledir} -type f -perm -0100 -name "*.so" | env -i tr '[:lower:]' '[:upper:]' | awk '{\
gsub(/.*\//,"");\
gsub(/^MOD_/,"");\
gsub(/^LIB/,"");\
gsub(/\.SO$/,"");\
print "-DHAVE_" $0}'`
echo ${moduleargs}
}
# 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 $"Starting $prog: "
daemon $httpd `moduleargs` $OPTIONS
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch /var/lock/subsys/httpd
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
killproc $httpd
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/httpd /var/run/httpd.pid }
reload() {
echo -n $"Reloading $prog: "
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
stop
start
fi
;;
reload)
reload
;;
graceful|help|configtest)
$apachectl $@
RETVAL=$?
;;
*)
echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"
exit 1
esac
exit $RETVAL