This module provides high-level tools for installing the apache2 web server and managing the configuration of web sites.
Require apache2 server to be installed and running.
from fabtools import require
require.apache.server()
Ensure link to /etc/apache2/mods-available/module exists and reload apache2 configuration if needed.
Ensure link to /etc/apache2/mods-available/module doesn’t exist and reload apache2 configuration if needed.
Ensure link to /etc/apache2/sites-available/config exists and reload apache2 configuration if needed.
Ensure link to /etc/apache2/sites-available/config doesn’t exist and reload apache2 configuration if needed.
Require an apache2 site.
You must provide a template for the site configuration, either as a string (template_contents) or as the path to a local template file (template_source).
from fabtools import require
CONFIG_TPL = '''
<VirtualHost *:%(port)s>
ServerName %(hostname})s
DocumentRoot %(document_root)s
<Directory %(document_root)s>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
'''
require.apache.site(
'example.com',
template_contents=CONFIG_TPL,
port=80,
hostname='www.example.com',
document_root='/var/www/mysite',
)
Ensure link to /etc/apache2/sites-available/config exists and reload apache2 configuration if needed.
Ensure link to /etc/apache2/sites-available/config doesn’t exist and reload apache2 configuration if needed.