Hi,
As a project for the school holidays, I am trying to write a PHP script that can add, remove and edit entire <VirtualHost> and <Directory> containters (as well as the directives contained inside them) from Apache's httpd.conf. This will mostly be running on a Windows test server.
Adding the lines to the conf file is easy - just check to see if it already exists and if not, append the text to the end of the file.
To edit/remove containers and directives, I thought I could try and match up lines using regular expressions (i.e delete a specified <Directory /dir-name-here> "tag" and then delete every line after that until I reach the closing "tag" - i.e. </Directory>). The problem is, I am quite inexperienced with PHP, and was wondering if anyone could get me going with some ideas on how to turn that idea into code?
Also comes the problem with grabbing information from the conf file and displaying it as a list on an HTML page (i.e. list all the VirtualHosts that exist).
If anyone can help, it is VERY much appreciated!
Thanks,
Ben Hodgson