What is a good library for managing Apache2 configuration files?

I would like to create a script for directly managing the configuration of Apache2, reading and writing its properties (for example, adding a new VirtualHost, changing the settings of an existing one).

Are there any libraries for Perl, Python, or Java that automate this task?

+7
java python perl apache
source share
6 answers

In Perl, you have at least 2 modules for this:

Apache :: ConfigFile

Apache :: Admin :: Config

+7
source share

Instead of manipulating configuration files, you can use mod_perl to directly embed Perl in configuration files. This may allow you, for example, to read the required vhosts from the database.

See Configure Apache with a Perl example for a quick example and Apache Perl Configuration for all details.

+7
source share

Check out Augeas , it's not specifically for the Apache-httpd config. files are just a common configuration. file "editor". One of the main selling points is that it will store comments / etc. I am glad to other tools for changing files and will refuse to give you the ability to save files with violations.

Also, the fact that you can use the same API in all the languages โ€‹โ€‹you requested, and that you can edit a different configuration. files using the same APIs are the main advantages of IMO.

+3
source share

This is the final Apache configurator:

http://perl.apache.org/

provides many, if not all, internal Apache components to Perl programs.

For example: http://perl.apache.org/docs/2.0/api/Apache2/Directive.html

(Of course, this can do much more than just configure it).

On the other hand, it needs to be downloaded and run in Apache, it is not a parser / editor of configuration files.

+2
source share
+2
source share

Also see Config :: General , which claims to be fully compatible with Apache configuration files. I use it to analyze Apache configuration files to automatically test regression after configuration changes.

0
source share

All Articles