5月 29th, 2009

httpd.conf内で変数を利用する

Posted in Apache by admin

httpd.confの内部で変数を扱うことが可能です。方法は単純で、apachectlを実行する前に変数を定義しておくだけです。Tomcatのcatalina.sh/setenv.shというファイル構成を真似れば、以下のような構成となります。

# setenv.sh
export INSTANCE="SERVICE"
export VHOST_1="www.hogehoge.com"
export VHOST_2="sub.hogehoge.com"
# 起動時の設定
if [ -r ${SERVER_ROOT}/bin/setenv.sh ]; then
	. ${SERVER_ROOT}/bin/setenv.sh
fi
${SERVER_ROOT}/bin/apachectl -d ${SERVER_ROOT} -k start -DSSL
exit $?
# httpd.conf
ErrorLog  /var/log/httpd/${INSTANCE}/${VHOST_1}/error.log
CustomLog /var/log/httpd/${INSTANCE}/${VHOST_1}/access.log

ディレクトリ名などhttpd.conf内に重複して設定しなくてはならない設定値がある場合、重宝する方法かもしれません。ちなみにこの変数はCGI実行時に参照できる環境変数とは異なります。CGIから取得したい環境変数はSetEnvディレクトリで定義して下さい。

You can leave a comment, or trackback from your own site. RSS 2.0

One comment

  1. max cleanse says:

    dmjtoxbmm.dmjnc, best colon cleanse, ZTrfhmd, [url=http://maxcleansespecialoffer.net/]best colon cleanse[/url], RsNFzbD, http://maxcleansespecialoffer.net/ max cleanse, JNIVHHI.

    11月 18th, 2011 at 4:23:08

Leave a comment