Apache の変数

Apache の変数

数百のサイトをホストする Apache Web サーバーをセットアップ中です。サイト固有の情報 (サーバー名、ドキュメント ルート、ディレクトリ、ログ パス) を除き、サイトの構成はほぼ同じになります。

各サイトの conf ファイルで変数を定義し、サイト設定を含むファイルをインクルードしたいと考えていました。

たとえば、site1.conf という設定ファイルを作成して、何らかの方法で次の変数を定義し、標準設定のインクルード ファイルを呼び出すとします。

Define subdomain site1
Include /etc/httpd/sitedefaults.conf

次に、sitedefaults.conf 内に、site1.conf で定義された変数を使用する次のような内容を追加します。

<VirtualHost 10.10.10.10:80>
  ServerName $subdomain.example.com
  DocumentRoot /var/www/$subdomain/

  ServerAdmin [email protected]

  ErrorLog /var/log/httpd/$subdomain/error.log
  CustomLog /var/log/httpd/$subdomain/access.log combined

  <Directory "/var/www/$subdomain/docs">
    Options FollowSymLinks Multiviews
    AllowOverride All
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>

このようなことは可能でしょうか?

関連情報