Apache 2.4를 mod_macro
과 함께 사용하고 있습니다. documentation에 따르면 동일한 구성 블록을 다시 쓰지 않으려면 여러 매크로를 인스턴스화 할 수 있습니다. 문서에서 예제 :Apache 2.4 mod_macro가 정의 된 모든 매크로를 인스턴스화하지 않습니다.
<Macro VHost $name $domain>
<VirtualHost *:80>
ServerName $domain
ServerAlias www.$domain
DocumentRoot "/var/www/vhosts/$name"
ErrorLog "/var/log/httpd/$name.error_log"
CustomLog "/var/log/httpd/$name.access_log" combined
</VirtualHost>
</Macro>
Use VHost example example.com
Use VHost myhost hostname.org
Use VHost apache apache.org
나는 다음과 같은 VirtualHost
구성 파일, 내 서버에 대해 동일한했다
<Macro VHost $request_uri>
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
DBDriver mysql
DBDParams "host=localhost port=3306 user=myself pass=myselfpass dbname=apacheauth"
DBDMin 2
DBDKeep 4
DBDMax 10
DBDExptime 300
<Location $request_uri>
AuthName $request_uri
AuthType Digest
AuthDigestAlgorithm MD5
AuthDigestDomain/
AuthDigestProvider dbd
AuthDBDUserRealmQuery "SELECT MD5(password) FROM password WHERE username = %s AND realm = %s"
Require valid-user
</Location>
</VirtualHost>
</Macro>
Use VHost /test
Use VHost /anothertest
prolem 구성 작업 내가 나에게 묻는 www.mysite.com/test
에 액세스 할 때이다 자격 증명을 묻지 않고 현재 페이지를 보여주는 www.mysite.com/anothertest
에 액세스하려고하면 자격 증명이 작동하지 않습니다. 서버가 첫 번째 Use 지시문에 대해서만 VirtualHost
을 인스턴스화하는 것처럼 보이며 다음을 모두 건너 뜁니다.