
我正在設定一個 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>
這樣的事情可能嗎?