memorandum
FrontPage
管理
ヘルプ
VineLinux3.x/Apache2.0/インストールおよび設定
をテンプレートにして作成
開始行:
* 概要 [#i25cd0b9]
WebサーバであるApache2をインストールします。APACHE(A PAtC...
http://www.apache.jp/
Vine Plusにrpmが用意されていますが、そのパッケージだとphp...
詳しくはこちら http://httpd.apache.org/docs/2.0/mpm.html
*設定手順 [#i677d4ed]
** SSL対応にする場合、openssl-develをあらかじめインストー...
# apt-get install openssl-devel
パッケージリストを読みこんでいます... 完了
依存情報ツリーを作成しています... 完了
以下のパッケージが新たにインストールされます:
openssl-devel
アップグレード: 0 個, 新規インストール: 1 個, 削除: 0 個...
1649kB のアーカイブを取得する必要があります。
展開後に 3788kB のディスク容量が追加消費されます。
取得:1 http://updates.vinelinux.org 3.1/i386/updates ope...
1649kB を 1s 秒で取得しました (1276kB/s)
変更を適用しています...
Preparing... #############################...
1:openssl-devel #############################...
完了
** apache2のダウンロード [#w858cc8e]
# wget http://www.apache.jp/dist/httpd/httpd-2.0.54.tar.gz
--13:25:20-- http://www.apache.jp/dist/httpd/httpd-2.0....
=> `httpd-2.0.54.tar.gz'
www.apache.jp をDNSに問いあわせています... 210.188.224.37
www.apache.jp[210.188.224.37]:80 に接続しています... 接...
HTTP による接続要求を送信しました、応答を待っています......
長さ: 7,508,193 [application/x-gzip]
[==============================================>] 7,508,...
13:25:36 (470.85 KB/s) - `httpd-2.0.54.tar.gz' を保存し...
** 解凍 [#adf4164c]
# tar zxf httpd-2.0.54.tar.gz
** インストール [#z3a9f390]
# cd httpd-2.0.54
# ./configure --enable-mods-shared='headers rewrite dav ...
configureオプションは適宜行ってください。-h オプションで...
>
--enable-mods-shared モジュール'headers rewrite dav dav-...
--enable-so DSOを有効にする
--with-ssl=/usr vine3.1の場合/usrを指定
--with-mpm=worker workerでコンパイル
DSO(Dynamic Shared Object)は、apache本体を軽くして必要が...
詳しくはこちら http://httpd.apache.org/docs/2.0/dso.html
モジュールについて
>
-1つずつ個別に入れたいとき
--enable-ssl=shared --enable-dav=shared --enable-dav-fs=...
-めんどくさいとき
--enable-mods-shared=most
これだと以下のモジュールがインストールされる。
mod_auth_digest.so* mod_ext_filter.so* mod_rewrite.so*
mod_access.so* mod_autoindex.so* mod_headers.so* ...
mod_actions.so* mod_cgi.so* mod_imap.so* ...
mod_alias.so* mod_dav.so* mod_include.so* ...
mod_asis.so* mod_dav_fs.so* mod_info.so* ...
mod_auth.so* mod_dir.so* mod_log_config.s...
mod_auth_anon.so* mod_env.so* mod_mime.so*
mod_auth_dbm.so* mod_expires.so* mod_negotiation....
-また、すべてのモジュールを入れたいとき
--enable-mods-shared=all
コンパイル、インストール
# make
# make install
標準では、/usr/local/apache2 にインストールされます。アン...
cgiスクリプトのためのシンボリックリンク
# ln -s /usr/bin/perl /usr/local/bin/perl
Document Root の作成
# mkdir -p /home/httpd/html
apacheを動作させるユーザの作成
# useradd -s /bin/false -d /dev/null apache
** 設定ファイルの編集 [#e71ba257]
# vi /usr/local/apache2/conf/httpd.conf
>
User apache ←先ほど作成したユーザを記述
Group apache
ServerAdmin
[email protected]
ServerName example.com:80
HostnameLookups On ←ホスト名の逆引きを行う
DocumentRoot "/home/httpd/html" ←index.htmlを置くディ...
<Directory "/home/httpd/html">
DirectoryIndex index.shtml index.html index.php ←〜/でア...
LogFormat "%h %l %u %t \"%!414r\" %>s %b \"%{Referer}i\"...
SetEnvIf Remote_Addr 192.168.0. homelog nolog ←ローカル...
SetEnvIf Remote_Addr 127.0.0.1 homelog nolog
SetEnvIf Request_URI "default.ida" wormlog nolog←ウイル...
SetEnvIf Request_URI "NULL.IDA" wormlog nolog
SetEnvIf Request_URI "root.exe" wormlog nolog
SetEnvIf Request_URI "cmd.exe" wormlog nolog
SetEnvIf Request_URI "Admin.dll" wormlog nolog
SetEnvIf Request_URI "sumthin" wormlog nolog
CustomLog logs/home_log common env=homelog ←環境変数home...
CustomLog logs/worm_log common env=wormlog ←環境変数worm...
CustomLog logs/access_log combined env=!nolog ←環境変数n...
ScriptAlias /cgi-bin/ "/home/httpd/cgi-bin/" ←cgiスクリ...
<Directory "/home/httpd/cgi-bin/">
AddHandler cgi-script .cgi ←cgiスクリプトを実行する
AddType text/html .shtml ←.shtmlでSSIを許可
AddOutputFilter INCLUDES .shtml ←.shtmlでSSIを許可
** 起動確認 [#j6b79ed2]
# /usr/local/apache2/bin/apachectl start
とやれば起動します。
# /usr/local/apache2/bin/apachectl stop
とやれば終了します。
** 動作の確認 [#rb24ba81]
/home/httpd/html に適当にindex.htmlを置いて、クライアント...
** 起動スクリプトの作成 [#i237d810]
/etc/rc.d/init.d/に起動スクリプトapache2を作ります。
tarボールには付属していないので、vineのrpmパッケージから...
# vi /etc/rc.d/ini.d/apache2
>
#!/bin/bash
#
# Startup script for the Apache Web Server
#
# chkconfig: - 85 15
# description: Apache is a World Wide Web server. It is...
# HTML files and CGI.
# processname: apache2
# pidfile: /usr/local/apache2/logs/httpd.pid
# config: /usr/local/apache2/conf/httpd.conf
# Source function library.
. /etc/rc.d/init.d/functions
if [ -f /etc/sysconfig/httpd ]; then
. /etc/sysconfig/httpd
fi
# This will prevent initlog from swallowing up a pass-ph...
# mod_ssl needs a pass-phrase from the user.
INITLOG_ARGS=""
# Path to the apachectl script, server binary, and short...
apachectl=/usr/local/apache2/bin/apachectl
httpd=/usr/local/apache2/bin/httpd
prog=httpd
RETVAL=0
# check for 1.3 configuration
check13 () {
CONFFILE=/usr/local/apache2/conf/httpd.conf
GONE="(ServerType|BindAddress|Port|AddModule|ClearModul...
GONE="${GONE}AgentLog|RefererLog|RefererIgnore|FancyInd...
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/apache2-2.0.50/...
failure "Apache 1.3 config directives test"
echo
exit 1
fi
}
# The semantics of these two functions differ from the w...
# things -- attempting to start while running is a failu...
# when not running is also a failure. So we just do it ...
# are expected to behave here.
start() {
echo -n $"Starting $prog: "
check13 || exit 1
if [ ! -f /usr/local/apache2/bin/httpd ] ; then
echo "test update alternatives"
/sbin/update-alternatives --auto apache2
fi
daemon $httpd $OPTIONS
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch /usr/local/apache2/logs...
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
killproc $httpd
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f /usr/local/apache2/logs/accept...
}
reload() {
echo -n $"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 /usr/local/apache2/logs/httpd.pid ] ; then
stop
start
fi
;;
reload)
reload
;;
graceful|help|configtest|fullstatus)
$apachectl $@
RETVAL=$?
;;
*)
echo $"Usage: $prog {start|stop|restart|condrestart|rel...
exit 1
esac
exit $RETVAL
保存したら、実行権限を与えます。
# chmod 755 /etc/rc.d/init.d/apache2
これで、
# /etc/rc.d/init.d/apache2 start
とやれば起動できます。
# /etc/rc.d/init.d/apache2 stop
とやれば停止できます。
** 自動起動するために、 [#ic37b485]
# ntsysv
を実行して、apache2にチェックをいれ、ブート時に起動するよ...
** 外部からアクセスできるように、ルータに穴を空ける [#q6b...
サーバマシンの80番ポートにアクセスできるように、ポートマ...
* Tips [#ge407292]
** ログファイルのローテーション [#rdfd1021]
このままだとログファイルが肥大化してディスクを圧迫するの...
/etc/logrotate.d/の下に、apacha2という設定ファイルを作成...
# vi /etc/logrotate.d/apache2
>
/usr/local/apache2/logs/*_log {
missingok ←ログファイルが存在しなくてもエラーを出さ...
sharedscripts ←複数のログファイルに対してpostrotate...
postrotate ←postrotateとendscriptの間に記述されたコ...
/bin/kill -HUP `cat /usr/local/apache2/logs/httpd.pi...
endscript
}
1行目でlogs/の*_logファイルをすべてローテーションさせる。~
5行目の/bin/kill〜でapacheを再起動しログファイルの切り替...
確認
# /usr/sbin/logrotate /etc/logrotate.d/apache2
実行しても何も表示されないが、エラーが出なければ多分大丈...
** 動作モードの確認 [#r156bc7c]
# /usr/local/apache2/bin/httpd -l
worker.c があればworkerで動いています。
* コメント [#p6e5ad2f]
#comment
終了行:
* 概要 [#i25cd0b9]
WebサーバであるApache2をインストールします。APACHE(A PAtC...
http://www.apache.jp/
Vine Plusにrpmが用意されていますが、そのパッケージだとphp...
詳しくはこちら http://httpd.apache.org/docs/2.0/mpm.html
*設定手順 [#i677d4ed]
** SSL対応にする場合、openssl-develをあらかじめインストー...
# apt-get install openssl-devel
パッケージリストを読みこんでいます... 完了
依存情報ツリーを作成しています... 完了
以下のパッケージが新たにインストールされます:
openssl-devel
アップグレード: 0 個, 新規インストール: 1 個, 削除: 0 個...
1649kB のアーカイブを取得する必要があります。
展開後に 3788kB のディスク容量が追加消費されます。
取得:1 http://updates.vinelinux.org 3.1/i386/updates ope...
1649kB を 1s 秒で取得しました (1276kB/s)
変更を適用しています...
Preparing... #############################...
1:openssl-devel #############################...
完了
** apache2のダウンロード [#w858cc8e]
# wget http://www.apache.jp/dist/httpd/httpd-2.0.54.tar.gz
--13:25:20-- http://www.apache.jp/dist/httpd/httpd-2.0....
=> `httpd-2.0.54.tar.gz'
www.apache.jp をDNSに問いあわせています... 210.188.224.37
www.apache.jp[210.188.224.37]:80 に接続しています... 接...
HTTP による接続要求を送信しました、応答を待っています......
長さ: 7,508,193 [application/x-gzip]
[==============================================>] 7,508,...
13:25:36 (470.85 KB/s) - `httpd-2.0.54.tar.gz' を保存し...
** 解凍 [#adf4164c]
# tar zxf httpd-2.0.54.tar.gz
** インストール [#z3a9f390]
# cd httpd-2.0.54
# ./configure --enable-mods-shared='headers rewrite dav ...
configureオプションは適宜行ってください。-h オプションで...
>
--enable-mods-shared モジュール'headers rewrite dav dav-...
--enable-so DSOを有効にする
--with-ssl=/usr vine3.1の場合/usrを指定
--with-mpm=worker workerでコンパイル
DSO(Dynamic Shared Object)は、apache本体を軽くして必要が...
詳しくはこちら http://httpd.apache.org/docs/2.0/dso.html
モジュールについて
>
-1つずつ個別に入れたいとき
--enable-ssl=shared --enable-dav=shared --enable-dav-fs=...
-めんどくさいとき
--enable-mods-shared=most
これだと以下のモジュールがインストールされる。
mod_auth_digest.so* mod_ext_filter.so* mod_rewrite.so*
mod_access.so* mod_autoindex.so* mod_headers.so* ...
mod_actions.so* mod_cgi.so* mod_imap.so* ...
mod_alias.so* mod_dav.so* mod_include.so* ...
mod_asis.so* mod_dav_fs.so* mod_info.so* ...
mod_auth.so* mod_dir.so* mod_log_config.s...
mod_auth_anon.so* mod_env.so* mod_mime.so*
mod_auth_dbm.so* mod_expires.so* mod_negotiation....
-また、すべてのモジュールを入れたいとき
--enable-mods-shared=all
コンパイル、インストール
# make
# make install
標準では、/usr/local/apache2 にインストールされます。アン...
cgiスクリプトのためのシンボリックリンク
# ln -s /usr/bin/perl /usr/local/bin/perl
Document Root の作成
# mkdir -p /home/httpd/html
apacheを動作させるユーザの作成
# useradd -s /bin/false -d /dev/null apache
** 設定ファイルの編集 [#e71ba257]
# vi /usr/local/apache2/conf/httpd.conf
>
User apache ←先ほど作成したユーザを記述
Group apache
ServerAdmin
[email protected]
ServerName example.com:80
HostnameLookups On ←ホスト名の逆引きを行う
DocumentRoot "/home/httpd/html" ←index.htmlを置くディ...
<Directory "/home/httpd/html">
DirectoryIndex index.shtml index.html index.php ←〜/でア...
LogFormat "%h %l %u %t \"%!414r\" %>s %b \"%{Referer}i\"...
SetEnvIf Remote_Addr 192.168.0. homelog nolog ←ローカル...
SetEnvIf Remote_Addr 127.0.0.1 homelog nolog
SetEnvIf Request_URI "default.ida" wormlog nolog←ウイル...
SetEnvIf Request_URI "NULL.IDA" wormlog nolog
SetEnvIf Request_URI "root.exe" wormlog nolog
SetEnvIf Request_URI "cmd.exe" wormlog nolog
SetEnvIf Request_URI "Admin.dll" wormlog nolog
SetEnvIf Request_URI "sumthin" wormlog nolog
CustomLog logs/home_log common env=homelog ←環境変数home...
CustomLog logs/worm_log common env=wormlog ←環境変数worm...
CustomLog logs/access_log combined env=!nolog ←環境変数n...
ScriptAlias /cgi-bin/ "/home/httpd/cgi-bin/" ←cgiスクリ...
<Directory "/home/httpd/cgi-bin/">
AddHandler cgi-script .cgi ←cgiスクリプトを実行する
AddType text/html .shtml ←.shtmlでSSIを許可
AddOutputFilter INCLUDES .shtml ←.shtmlでSSIを許可
** 起動確認 [#j6b79ed2]
# /usr/local/apache2/bin/apachectl start
とやれば起動します。
# /usr/local/apache2/bin/apachectl stop
とやれば終了します。
** 動作の確認 [#rb24ba81]
/home/httpd/html に適当にindex.htmlを置いて、クライアント...
** 起動スクリプトの作成 [#i237d810]
/etc/rc.d/init.d/に起動スクリプトapache2を作ります。
tarボールには付属していないので、vineのrpmパッケージから...
# vi /etc/rc.d/ini.d/apache2
>
#!/bin/bash
#
# Startup script for the Apache Web Server
#
# chkconfig: - 85 15
# description: Apache is a World Wide Web server. It is...
# HTML files and CGI.
# processname: apache2
# pidfile: /usr/local/apache2/logs/httpd.pid
# config: /usr/local/apache2/conf/httpd.conf
# Source function library.
. /etc/rc.d/init.d/functions
if [ -f /etc/sysconfig/httpd ]; then
. /etc/sysconfig/httpd
fi
# This will prevent initlog from swallowing up a pass-ph...
# mod_ssl needs a pass-phrase from the user.
INITLOG_ARGS=""
# Path to the apachectl script, server binary, and short...
apachectl=/usr/local/apache2/bin/apachectl
httpd=/usr/local/apache2/bin/httpd
prog=httpd
RETVAL=0
# check for 1.3 configuration
check13 () {
CONFFILE=/usr/local/apache2/conf/httpd.conf
GONE="(ServerType|BindAddress|Port|AddModule|ClearModul...
GONE="${GONE}AgentLog|RefererLog|RefererIgnore|FancyInd...
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/apache2-2.0.50/...
failure "Apache 1.3 config directives test"
echo
exit 1
fi
}
# The semantics of these two functions differ from the w...
# things -- attempting to start while running is a failu...
# when not running is also a failure. So we just do it ...
# are expected to behave here.
start() {
echo -n $"Starting $prog: "
check13 || exit 1
if [ ! -f /usr/local/apache2/bin/httpd ] ; then
echo "test update alternatives"
/sbin/update-alternatives --auto apache2
fi
daemon $httpd $OPTIONS
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch /usr/local/apache2/logs...
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
killproc $httpd
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f /usr/local/apache2/logs/accept...
}
reload() {
echo -n $"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 /usr/local/apache2/logs/httpd.pid ] ; then
stop
start
fi
;;
reload)
reload
;;
graceful|help|configtest|fullstatus)
$apachectl $@
RETVAL=$?
;;
*)
echo $"Usage: $prog {start|stop|restart|condrestart|rel...
exit 1
esac
exit $RETVAL
保存したら、実行権限を与えます。
# chmod 755 /etc/rc.d/init.d/apache2
これで、
# /etc/rc.d/init.d/apache2 start
とやれば起動できます。
# /etc/rc.d/init.d/apache2 stop
とやれば停止できます。
** 自動起動するために、 [#ic37b485]
# ntsysv
を実行して、apache2にチェックをいれ、ブート時に起動するよ...
** 外部からアクセスできるように、ルータに穴を空ける [#q6b...
サーバマシンの80番ポートにアクセスできるように、ポートマ...
* Tips [#ge407292]
** ログファイルのローテーション [#rdfd1021]
このままだとログファイルが肥大化してディスクを圧迫するの...
/etc/logrotate.d/の下に、apacha2という設定ファイルを作成...
# vi /etc/logrotate.d/apache2
>
/usr/local/apache2/logs/*_log {
missingok ←ログファイルが存在しなくてもエラーを出さ...
sharedscripts ←複数のログファイルに対してpostrotate...
postrotate ←postrotateとendscriptの間に記述されたコ...
/bin/kill -HUP `cat /usr/local/apache2/logs/httpd.pi...
endscript
}
1行目でlogs/の*_logファイルをすべてローテーションさせる。~
5行目の/bin/kill〜でapacheを再起動しログファイルの切り替...
確認
# /usr/sbin/logrotate /etc/logrotate.d/apache2
実行しても何も表示されないが、エラーが出なければ多分大丈...
** 動作モードの確認 [#r156bc7c]
# /usr/local/apache2/bin/httpd -l
worker.c があればworkerで動いています。
* コメント [#p6e5ad2f]
#comment
ページ名:
検索
AND検索
OR検索
編集操作
一覧
単語検索
最終更新
バックアップ
ヘルプ
トップページ
http://kayanomori.net/
↑
アクセス数
本日:0人
昨日:0人
総数:0人
現在:2人
最新の20件
2022-07-16
投票箱
2022-01-30
FrontPage
2022-01-29
めも
2018-02-03
SandBox
PukiWiki
InterWikiName
FormattingRules
PukiWiki/1.4/Manual/Plugin/O-R
PukiWiki/1.4/Manual/Plugin/S-U
InterWiki
日本語
複数画像アップ掲示板 ECOUP(エコアップ) v1.31
日記/2006-12-12
日記
日記/2005-10-04
特定のオートコンプリート履歴だけを削除する
日記/2005-10-06
小ネタ集/WordPress
日記/2005-10-05
整形ルール
edit