This PHP script provides a set of functions for generating, editing, and parsing Apache configuration files. It simplifies the process of managing virtual hosts and directives, making it easier to customize your Apache server.
The Apache Configuration Manager is a PHP script designed to streamline the management of Apache configuration files. It includes functions for generating Apache configurations from JSON input, editing directives, and parsing existing configurations.
To run this script, you'll need:
- PHP (PHP 5.4 or higher) installed on your system.
- Access to the Apache configuration file you want to edit.
- Clone the repository:
git clone https://github.com/StunsIO/PHP-Apache-Site-Config-Editor-CLI.git
php apache_config_cli.php <file_path> <directive> <key> <value>
<file_path>
: Path to the Apache configuration file.<directive>
: The directive to edit.<key>
: The key to edit within the directive.<value>
: The new value for the specified key.
generate_apache_config($config)
Generates an Apache configuration from a JSON/Array input.edit_apache($config_string, $directive, $key, $value)
Edits an Apache directive with a new value.parse_apache_config($file_path)
Parses an Apache configuration file and returns it as an associative array.
php apache_config_cli.php /etc/apache2/sites-available/default-ssl.conf 'VirtualHost *:443' 'DocumentRoot' '/var/www/html'