httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rbo...@apache.org
Subject svn commit: r1525476 - /httpd/httpd/branches/2.4.x/docs/manual/mod/mod_macro.xml
Date Mon, 23 Sep 2013 00:17:51 GMT
Author: rbowen
Date: Mon Sep 23 00:17:51 2013
New Revision: 1525476

URL: http://svn.apache.org/r1525476
Log:
Merges doc restructure from trunk.

Modified:
    httpd/httpd/branches/2.4.x/docs/manual/mod/mod_macro.xml   (contents, props changed)

Modified: httpd/httpd/branches/2.4.x/docs/manual/mod/mod_macro.xml
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/docs/manual/mod/mod_macro.xml?rev=1525476&r1=1525475&r2=1525476&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/docs/manual/mod/mod_macro.xml (original)
+++ httpd/httpd/branches/2.4.x/docs/manual/mod/mod_macro.xml Mon Sep 23 00:17:51 2013
@@ -23,76 +23,153 @@
 <modulesynopsis metafile="mod_macro.xml.meta">
 
 <name>mod_macro</name>
-<description>This module provides usage of macros within apache runtime configuration
files</description>
+<description>Provides macros within apache httpd runtime configuration files</description>
 <status>Base</status>
 <sourcefile>mod_macro.c</sourcefile>
 <identifier>macro_module</identifier>
-<compatibility>Available in Apache HTTPD 2.4.5 and later</compatibility>
 
 <summary>
 
-    <p>This module provides macros within apache runtime configuration files.
-    These macros have parameters.  They are expanded when used (parameters are
-    substituted by their values given as an argument), and the result is
-    processed normally.</p>
+    <p>Provides macros within Apache httpd runtime configuration files,
+    to ease the process of creating numerous similar configuration
+    blocks. When the server starts up, the macros are expanded using the
+    provided parameters, and the result is processed as along with the
+    rest of the configuration file.</p>
+
 </summary>
 
-<section id="features"><title>Features</title>
+<section id="usage"><title>Usage</title>
+
+<p>Macros are defined using <directive
+type="section">Macro</directive> blocks, which contain the portion of
+your configuration that needs to be repeated, complete with variables
+for those parts that will need to be substituted.</p>
+
+<p>For example,  you might use a macro to define a <directive
+type="section">VirtualHost</directive> block, in order to define
+multiple similar virtual hosts:</p>
+
+<highlight language="config">
+&lt;Macro VHost $name $domain&gt;
+&lt;VirtualHost *:80&gt;
+    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
+&gt;/VirtualHost&gt;
+&lt;/Macro&gt;
+</highlight>
 
- <p>Definition of a macro:</p>
-    <ul>
-    <li> macro definition within a &lt;Macro&gt; section, following
-         the apache style.</li>
-    <li> user defined names for the macro and its parameters.</li>
-    <li> macro names are case-insensitive, like apache directives.</li>
-    <li> macro parameter names are case sensitive.</li>
-    <li> macro parameters must have distinct names.</li>
-    <li> error on empty parameter names.</li>
-    <li> redefining a macro generates a warning.</li>
-    <li> macro definitions can be nested... (but what for?)</li>
-    <li> warn about unused macro parameters.</li>
-    <li> warn about macro parameter names which prefix one another.</li>
-    <li> warn if a parameter is not prefixed by any of '<code>$%@</code>'
-         (good practice).</li>
-    <li> the available prefixes help deal with interactions with other
-         directives such as <directive module="core">Define</directive>.</li>
-    <li> tip: it may be useful to define a macro parameter with surrounding
-         braces, say <code>${foo}</code> so that the name can appear with
-	 surrounding characters such as <code>bla${foo}bla</code>.</li>
-    <li> warn about empty macro contents.</li>
-    <li> warns if sections are not properly nested within a macro.
-         (if it is detected so).</li>
-    <li> the lexical scope of macro parameters is restricted to the macro text,
-         it is not forwarded to includes for instance.</li>
-    <li> arbitrary contents in macros.
-         <p>It means you can put perl sections or whatever you like in a macro.
-	 No assumption is made about the lexical structure (quotes, spaces or
-         whatever) within the macro contents but to expect a set of
-         backslash-continued independent lines.</p></li>
-    </ul>
-
-    <p>Use of a macro:</p>
-    <ul>
-    <li> number of arguments must match the definition.</li>
-    <li> all occurences of macro parameters are substituted by their values.</li>
-    <li> in case of conflicts, the longest parameter name is chosen.</li>
-    <li> macro expansion recursion is detected and stopped (error).</li>
-    <li> warn about empty arguments when used.</li>
-    <li> on errors, try to describe precisely where the error occured.</li>
-    <li> <code>$</code> and <code>%</code>-prefixed parameters
are not
-          escaped.</li>
-    <li> <code>@</code>-prefixed parameters are escaped in quotes.</li>
-    </ul>
-
-   <p>Removal of a macro definition:</p>
-   <ul>
-   <li> the macro must be already defined.</li>
- </ul>
+<p>Macro names are case-insensitive, like httpd configuration
+directives. However, variable names are case sensitive.</p>
 
-    <highlight language="config">
+<p>You would then invoke this macro several times to create virtual
+hosts:</p>
+
+<highlight language="config">
+Use VHost example example.com
+Use VHost myhost hostname.org
+Use VHost apache apache.org
+
+UndefMacro VHost
+</highlight>
+
+<p>At server startup time, each of these <directive>Use</directive>
+invocations would be expanded into a full virtualhost, as
+described by the <directive>Macro</directive> definition.</p>
+
+<p>The <directive>UndefMacro</directive> directive is used so that later
+macros using the same variable names don't result in conflicting
+definitions.</p>
+
+<p>A more elaborate version of this example may be seen below in the
+Examples section.</p>
+
+</section>
+
+<section id="tips"><title>Tips</title>
+
+<p>Parameter names should begin with a sigil such as <code>$</code>,
+<code>%</code>, or <code>@</code>, so that they are clearly
+identifiable, and also in order to help deail with interactions with
+other directives, such as the core <directive
+module="core">Define</directive> directive. Failure to do so will 
+result in a warning. Nevertheless, you are encouraged to have a good
+knowledge of your entire server configuration in order to avoid reusing
+the same variables in different scopes, which can cause confusion.</p>
+
+<p>Parameters prefixed with either <code>$</code> or <code>%</code>
are
+not escaped. Parameters prefixes with <code>@</code> are escaped in
+quotes.</p>
+
+<p>Avoid using a parameter which contains another parameter as a prefix,
+(For example, <code>$win</code> and <code>$winter</code>) as this
may
+cause confusion at expression evaluation time. In the event of such
+confusion, the longest possible parameter name is used.</p>
+
+<p>If you want to use a value within another string, it is useful to
+surround the parameter in braces, to avoid confusion:</p>
+
+<highlight language="config">
+&lt;Macro DocRoot ${docroot}&gt;
+    DocumentRoot /var/www/${docroot}/htdocs
+&lt;/Macro&gt;
+</highlight>
+
+</section>
+
+<section id="examples">
+<title>Examples</title>
+
+<section>
+<title>Virtual Host Definition</title>
+
+<p>A common usage of <module>mod_macro</module> is for the creation of
+dynamically-generated virtual hosts.</p>
+
+<highlight language="config">
+## Define a VHost Macro for repetitive configurations
+
+&lt;Macro VHost $host $port $dir&gt;
+  Listen $port
+  &lt;VirtualHost *:$port&gt;
+
+    ServerName $host
+    DocumentRoot $dir
+
+    # Public document root
+    &lt;Directory $dir&gt;
+        Require all granted
+    &lt;/Directory&gt;
+
+    # limit access to intranet subdir.
+    &lt;Directory $dir/intranet&gt;
+      Require ip 10.0.0.0/8
+    &lt;/Directory&gt;
+  &lt;/VirtualHost&gt;
+&lt;/Macro&gt;
+
+## Use of VHost with different arguments.
+
+Use VHost www.apache.org 80 /vhosts/apache/htdocs
+Use VHost example.org 8080 /vhosts/example/htdocs
+Use VHost www.example.fr 1234 /vhosts/example.fr/htdocs
+</highlight>
+</section> <!-- Vhosts -->
+
+<section>
+<title>Removal of a macro definition</title>
+
+<p>It's recommended that you undefine a macro once you've used it. This
+avoids confusion in a complex configuration file where there may be
+conflicts in variable names.</p>
+
+<highlight language="config">
 &lt;Macro DirGroup $dir $group&gt;
   &lt;Directory $dir&gt;
-    require group $group
+    Require group $group
   &lt;/Directory&gt;
 &lt;/Macro&gt;
 
@@ -100,8 +177,11 @@ Use DirGroup /www/apache/private private
 Use DirGroup /www/apache/server  admin
 
 UndefMacro DirGroup
-    </highlight>
-</section>
+</highlight>
+
+</section> <!-- UndefMacro -->
+
+</section> <!-- Example -->
 
 <!-- Macro -->
 <directivesynopsis type="section">
@@ -150,7 +230,7 @@ UndefMacro DirGroup
 </contextlist>
 
 <usage>
-    <p> The <directive>Use</directive> directive controls the use of a
macro.
+    <p>The <directive>Use</directive> directive controls the use of a macro.
     The specified macro is expanded. It must be given the same number of
     arguments than in the  macro definition. The provided values are
     associated to their corresponding initial parameters and are substituted
@@ -170,11 +250,12 @@ Require ip 10.2.16.0/24
 Require ip 192.54.172.0/24 192.54.148.0/24
     </highlight>
 </usage>
+
 </directivesynopsis>
 
 <!-- UndefMacro -->
 <directivesynopsis>
-<name>undefMacro</name>
+<name>UndefMacro</name>
 <description>Undefine a macro</description>
 
 <syntax>UndefMacro <var>name</var></syntax>
@@ -194,4 +275,5 @@ UndefMacro RestrictedAccessPolicy
     </highlight>
 </usage>
 </directivesynopsis>
+
 </modulesynopsis>

Propchange: httpd/httpd/branches/2.4.x/docs/manual/mod/mod_macro.xml
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Mon Sep 23 00:17:51 2013
@@ -0,0 +1,3 @@
+/httpd/httpd/branches/revert-ap-ldap/docs/manual/mod/mod_macro.xml:1150158-1150173
+/httpd/httpd/branches/wombat-integration/docs/manual/mod/mod_macro.xml:723609-723841
+/httpd/httpd/trunk/docs/manual/mod/mod_macro.xml:1200475,1200478,1200482,1200491,1200496,1200513,1200550,1200556,1200580,1200605,1200612,1200614,1200639,1200646,1200656,1200667,1200679,1200699,1200702,1200955,1200957,1200961,1200963,1200968,1200975,1200977,1201032,1201042,1201111,1201194,1201198,1201202,1201443,1201450,1201460,1201956,1202236,1202453,1202456,1202886,1203400,1203491,1203632,1203714,1203859,1203980,1204630,1204968,1204990,1205061,1205075,1205379,1205885,1206291,1206472,1206587,1206850,1206940,1206978,1207719,1208753,1208835,1209053,1209085,1209417,1209432,1209461,1209601,1209603,1209618,1209623,1209741,1209754,1209766,1209776,1209797-1209798,1209811-1209812,1209814,1209908,1209910,1209913,1209916-1209917,1209947,1209952,1210067,1210080,1210120,1210124,1210130,1210148,1210219,1210221,1210252,1210284,1210336,1210378,1210725,1210892,1210951,1210954,1211351-1211352,1211364,1211490,1211495,1211528,1211663,1211680,1212872,1212883,1213338,1213380-1213381,1213391,1213399,1213
 567,1214003,1214005,1214015,1215514,1220462,1220467,1220493,1220524,1220570,1220768,1220794,1220826,1220846,1221205,1221292,1222335,1222370,1222473,1222915,1222917,1222921,1222930,1223048,1225060,1225197-1225199,1225223,1225380,1225476,1225478,1225791,1225795-1225796,1226339,1226375,1227910,1228700,1228816,1229024,1229059,1229099,1229116,1229134,1229136,1229930,1230286,1231255,1231257,1231442,1231446,1231508,1231510,1231518,1232575,1232594,1232630,1232838,1234180,1234297,1234479,1234511,1234565,1234574,1234642-1234643,1234876,1234899,1235019,1236122,1236701,1237407,1238545,1238768,1239029-1239030,1239071,1239565,1240315,1240470,1240778,1241069,1241071,1242089,1242798,1242967,1243176,1243246,1243797,1243799,1244211,1245717,1290823,1290835,1291819-1291820,1291834,1291840,1292043,1293405,1293534-1293535,1293658,1293678,1293708,1294306,1294349,1294356,1294358,1294372,1294471,1297560,1299718,1299786,1300766,1301111,1301725,1302444,1302483,1302653,1302665,1302674,1303201,1303435,1303827,1
 304087,1304874-1304875,1305167,1305586,1306350,1306409,1306426,1306841,1307790,1308327,1308459,1309536,1309567,1311468,1324760,1325218,1325227,1325250,1325265,1325275,1325632,1325724,1326980,1326984,1326991,1327689,1328325-1328326,1328339,1328345,1328950,1330189,1330964,1331115,1331942,1331977,1332378,1333969,1334343,1335882,1337344,1341906,1341913,1343085,1343087,1343094,1343099,1343935,1345319,1345329,1346905,1348036,1348656,1348660,1349905,1351012-1351020,1351071-1351072,1351074,1351737,1352047,1352534,1352909-1352912,1357685,1358061,1359057,1359881,1361153,1361298,1361766,1361773,1361778,1361784,1361791-1361792,1361801,1361803,1362020,1362538,1362707,1363035,1363183,1363186,1363440,1363557,1363589,1363829,1363832,1363836-1363837,1363853,1364133,1364138,1364229,1364601,1365001,1365020,1365029,1365479,1366319,1366344,1366621,1367778,1367819,1368053,1368058,1368094,1368131,1368393,1368396,1369419,1369568,1369604,1369618,1369904,1369995,1369999,1370001,1370466,1370592,1370615-137061
 6,1370763,1371387,1371791,1371801,1371878,1371903,1373270,1373447,1373898,1373955,1374157,1374199,1374877,1374880,1375006,1375009,1375011,1375013,1375584,1376695,1376700,1378178,1383490,1384408,1384913,1386576,1386578,1386726,1386822,1386913,1387085,1387088,1387110,1387444,1387603,1387607,1387633,1387693,1387979,1388029,1388648,1388660,1388825,1388899,1389316,1389339,1389481,1389506,1389564,1390562,1390564,1391396,1391398,1392214,1392345-1392347,1392850,1393033,1393058,1393338,1393564,1395225,1397636,1397687,1397710,1397716,1398025,1398040,1398481,1399413,1399687,1400700,1401448,1403041,1404653,1405407,1405856,1405973,1406760,1407004,1407006,1407085,1407088,1407381,1407459-1407460,1407528,1408958,1408961,1409170,1414094,1415075,1415549,1415960,1416278,1417197,1418524,1418556,1418648,1418769,1419719,1419726,1419755,1419781,1420120,1420124,1420685-1420686,1421288,1421851,1421912,1421953,1422943,1422980,1425771-1425772,1425775,1425874,1428184,1429228,1430575,1433861,1435811,1437808,143
 7821,1437826,1437833,1437836,1439106,1439404,1442309,1442326,1442759,1442865,1448171,1448453,1452911,1452949,1452954,1453022,1453574,1453875-1453876,1453963,1454386,1454414-1454415,1457471,1457504,1458285,1458447,1462266,1462269,1463455,1468581,1470679,1477094,1481359,1481396,1484910,1487451,1488164,1491155,1492710,1492782,1496338,1498880,1502665,1514214,1517386,1518265,1520908,1524101,1525426-1525474



Mime
View raw message