I publish this topic based on the topic Programming in PHP for the command line , in which, in my opinion, the not very optimal process of adding virtual hosts using PHP in the command line mode is described. For those of you who are familiar with mod_macro , this topic will seem uninteresting and you can skip it. So, the next task is to easily add new virtual hosts to apache. The first thing that comes to mind is to describe the virtual host pattern in the form of a macro that can be used more than once, in which the mod_macro module will help us.
Install mod_macro (installation for debian / ubuntu, but for other systems there should be no difficulties) and turn it on