
    >>> import os
    >>> data_dir = os.path.join(test_dir, 'data')
    >>> parts_dir = os.path.join(data_dir, 'parts')
    >>> buildout = {'instance': {'location': test_dir},
    ...             'buildout': {'directory': test_dir,
    ...                          'parts-directory': test_dir}}
    >>> name = 'apache_config'

    >>> options = { 'mainconfig': '/usr/local/apache/config/httpd.conf',
    ...             'bind' : 80,
    ...             'backends' : 'plone.org:127.0.0.1:3128',
    ...             'zope2_vhm_map' : 'plone.org:/plone',
    ...             'log_format' : 'combined',
    ...            }

    >>> from plone.recipe.apache import ConfigureRecipe
    >>> recipe = ConfigureRecipe(buildout, name, options)

    >>> main_config = open(os.path.join(test_dir,'httpd.conf'),'w')
    >>> main_config.write('## apache main  config\n')
    >>> main_config.close()
    >>> options['mainconfig'] = os.path.join(test_dir,'httpd.conf')
    >>> recipe = ConfigureRecipe(buildout, name, options)


Verify configuration of backends and zope2_vhm_map::

    >>> recipe.backends
    [{'_vhm_path': None, 'host': 'plone.org', 'backend_port': '3128', 'backend_host': '127.0.0.1'}]

    >>> recipe.zope2_vhm_maps
    {'plone.org': ['plone']}


And now install::

    >>> path = recipe.install()
    ... tests/apache_config/conf.d'

    >>> f = open(os.path.join(path,'virtual_plone.org.conf'))
    >>> print f.read()
    <VirtualHost *:80>
        ServerName plone.org
    <BLANKLINE>
        RewriteEngine On
        RewriteLog ...
        RewriteLogLevel 0
    <BLANKLINE>
        CustomLog ...
        ErrorLog ...
    <BLANKLINE>
        <Proxy http://127.0.0.1:3128>
          Allow from all
        </Proxy>
    <BLANKLINE>
        RewriteRule ^(.*)$ - [E=BACKEND_LOCATION:127.0.0.1]
        RewriteRule ^(.*)$ - [E=BACKEND_PORT:3128]
        RewriteRule ^(.*)$ - [E=HOST:plone.org]
        RewriteRule ^(.*)$ - [E=PORT:80]
        RewriteRule ^(.*)$ - [E=PROTO:http]
        RewriteRule ^(.*)$ - [E=ZOPEPATH:plone]
        RewriteRule  ^/(.*)/$ http://%{ENV:BACKEND_LOCATION}:%{ENV:BACKEND_PORT}/VirtualHostBase/%{ENV:PROTO}/%{ENV:HOST}:%{ENV:PORT}/%{ENV:ZOPEPATH}/VirtualHostRoot/$1 [L,P]
        RewriteRule  ^/(.*)$ http://%{ENV:BACKEND_LOCATION}:%{ENV:BACKEND_PORT}/VirtualHostBase/%{ENV:PROTO}/%{ENV:HOST}:%{ENV:PORT}/%{ENV:ZOPEPATH}/VirtualHostRoot/$1 [L,P]
    <BLANKLINE>
    <BLANKLINE>
    </VirtualHost>
    <BLANKLINE>
    <BLANKLINE>

Ok add an another::

    >>> options['backends'] = """
    ...               plone.org:127.0.0.1:3128
    ...               plone2.org/plone:127.0.0.1:3128
    ...                """
    >>> recipe = ConfigureRecipe(buildout, name, options)
    >>> path = recipe.install()
    >>> f = open(os.path.join(path,'virtual_plone2.org.conf'))
    >>> print f.read()
    <VirtualHost *:80>
        ServerName plone2.org
    <BLANKLINE>
        RewriteEngine On
        RewriteLog ...var/log/rewrite_plone2.org.log
        RewriteLogLevel 0
    <BLANKLINE>
        CustomLog ...var/log/access_plone2.org.log combined
        ErrorLog ...var/log/error_plone2.org.log
    <BLANKLINE>
        <Proxy http://127.0.0.1:3128>
          Allow from all
        </Proxy>
    <BLANKLINE>
        RewriteRule ^(.*)$ - [E=BACKEND_LOCATION:127.0.0.1]
        RewriteRule ^(.*)$ - [E=BACKEND_PORT:3128]
        RewriteRule ^(.*)$ - [E=HOST:plone2.org]
        RewriteRule ^(.*)$ - [E=PORT:80]
        RewriteRule ^(.*)$ - [E=PROTO:http]
        RewriteRule  ^/(.*)/$ http://%{ENV:BACKEND_LOCATION}:%{ENV:BACKEND_PORT}/$1 [L,P]
        RewriteRule  ^/(.*)$ http://%{ENV:BACKEND_LOCATION}:%{ENV:BACKEND_PORT}/$1 [L,P]
    <BLANKLINE>
    </VirtualHost>
    <BLANKLINE>
    <BLANKLINE>

    >>> options['zope2_vhm_map'] = """
    ...               plone.org:/plone
    ...               plone2.org:/fake
    ...                """

    >>> recipe = ConfigureRecipe(buildout, name, options)
    >>> recipe.zope2_vhm_maps
    {'plone2.org': ['fake'], 'plone.org': ['plone']}


    >>> path = recipe.install()
    >>> f = open(os.path.join(path,'virtual_plone2.org.conf'))
    >>> print f.read()
    <VirtualHost *:80>
    ServerName plone2.org
    <BLANKLINE>
        RewriteEngine On
        RewriteLog .../var/log/rewrite_plone2.org.log
        RewriteLogLevel 0
    <BLANKLINE>
        CustomLog .../var/log/access_plone2.org.log combined
        ErrorLog .../var/log/error_plone2.org.log
    <BLANKLINE>
        <Proxy http://127.0.0.1:3128>
          Allow from all
        </Proxy>
    <BLANKLINE>
        RewriteRule ^(.*)$ - [E=BACKEND_LOCATION:127.0.0.1]
        RewriteRule ^(.*)$ - [E=BACKEND_PORT:3128]
        RewriteRule ^(.*)$ - [E=HOST:plone2.org]
        RewriteRule ^(.*)$ - [E=PORT:80]
        RewriteRule ^(.*)$ - [E=PROTO:http]
        RewriteRule ^(.*)$ - [E=ZOPEPATH:fake]
        RewriteRule  ^/plone(.*)$ http://%{ENV:BACKEND_LOCATION}:%{ENV:BACKEND_PORT}/VirtualHostBase/%{ENV:PROTO}/%{ENV:HOST}:%{ENV:PORT}/%{ENV:ZOPEPATH}/VirtualHostRoot/_vh_plone$1 [L,P]
        RewriteRule  ^/(.*)$ http://%{ENV:BACKEND_LOCATION}:%{ENV:BACKEND_PORT}/VirtualHostBase/%{ENV:PROTO}/%{ENV:HOST}:%{ENV:PORT}/%{ENV:ZOPEPATH}/VirtualHostRoot/_vh_plone/$1 [L,P]
    <BLANKLINE>
    <BLANKLINE>
    </VirtualHost>
    <BLANKLINE>
    <BLANKLINE>

    >>> f = open(options['mainconfig'])
    >>> print f.read()
    ## apache main  config
    Include .../apache_config/conf.d/*.conf
    <BLANKLINE>






