cPanel & WHM Version 94 has been released, and brings a slew of great updates. Take a look at what is included, and then upgrade today!

API or Script to edit apache configuration

Tim Duncan shared this idea 2 years ago
Completed

As a cPanel System Administrator, I would like to be able to use a script or API call to modify apache configuration settings located inside /var/cpanel/conf/apache/local instead of having to edit this via WHM or manually via SSH, so that we can automate apache settings across multiple WHM servers. This would give us the ability to configure things such as 'Perfect SSL secrecy' etc via automated scripts.

Best Answer
photo

In cPanel & WHM Version 84 we added the following:

Apache configuration file changes

In cPanel & WHM version 84, we created the /etc/cpanel/ea4/ea4.conf file. This file consolidates all of your webserver's options into a single JSON file. This file replaces the /var/cpanel/conf/apache/local and /var/cpanel/conf/apache/main files. The system will back up the current contents of these files to the root-home-dir /legacy_ea3_distiller_files-timestamp.tar.gz file, where root-home-dir represents the root user's home directory and timestamp represents a timestamp.

The WHM interface provides several ways to customize your Apache configuration:

  • cPanel & WHM sets several Apache directives by default. These directives affect the whole server. To change these directives, use WHM's Global Configuration interface (WHM >> Home >> Service Configuration >> Apache Configuration >> Global Configuration).
  • To modify the Apache configuration's include files through WHM, use WHM's Include Editor interface (WHM >> Home >> Service Configuration >> Apache Configuration >> Include Editor).

We provide several other methods to customize your system. You can use one of the following methods to create custom configurations:

For more information, read our Advanced Apache Configuration documentation.

If you are a third-party integrator who wants a custom Apache configuration, read our Guide to Perl in cPanel - Apache Configuration documentation for more information.

Comments (3)

photo
1

If you are wanting all of your server's Apache configs to be the same, why not just copy the /var/cpanel/conf/apache/local file across all of your servers and rebuid apache with /scripts/rebuildhttpdconf ?


You can also parse /var/cpanel/conf/apache/local as a YAML file (see the YAML extension in PHP - yaml_parse() - to parse the contents into a usable array.

photo
3

The request here is for an API call, which would ensure long-term compatibility. Manually copying files could have problems if we change how or where a configuration is managed.

photo
4

Benny is spot on!

Copying the files is not a valid solution for us, as each server will most likely need different configuration. We could write custom scripts using 'sed' for example, but if the file format is ever updated these scripts would break, which is why a supported API call would be ideal.


cPanel already has scripts/API calls to update SSL ciphers for example in dovecot, exim, whostmgrd, etc, but not Apache which I thought was strange.

We also don't want to have to use PHP in system admin tasks..

:)

photo
photo
2

Since "/var/cpanel/conf/apache/local" in cPanel 84 is deprecated our automated deployment will be broken. We need some way to change apache configuration without human intervention.

photo
1

In cPanel & WHM Version 84 we added the following:

Apache configuration file changes

In cPanel & WHM version 84, we created the /etc/cpanel/ea4/ea4.conf file. This file consolidates all of your webserver's options into a single JSON file. This file replaces the /var/cpanel/conf/apache/local and /var/cpanel/conf/apache/main files. The system will back up the current contents of these files to the root-home-dir /legacy_ea3_distiller_files-timestamp.tar.gz file, where root-home-dir represents the root user's home directory and timestamp represents a timestamp.

The WHM interface provides several ways to customize your Apache configuration:

  • cPanel & WHM sets several Apache directives by default. These directives affect the whole server. To change these directives, use WHM's Global Configuration interface (WHM >> Home >> Service Configuration >> Apache Configuration >> Global Configuration).
  • To modify the Apache configuration's include files through WHM, use WHM's Include Editor interface (WHM >> Home >> Service Configuration >> Apache Configuration >> Include Editor).

We provide several other methods to customize your system. You can use one of the following methods to create custom configurations:

For more information, read our Advanced Apache Configuration documentation.

If you are a third-party integrator who wants a custom Apache configuration, read our Guide to Perl in cPanel - Apache Configuration documentation for more information.

Leave a Comment
 
Attach a file