I have an dedicated server where i have to create multiple virtual hosts.So for this i have managed to create .conf file in /apache2/sites-available folder using php,but next step is to add that virtual host entry in host file which is at /etc/hosts.
I can do this using Linux command by editing hosts file in nano
editor,But i want to do this using php.
I found this command which add entry in host file using terminal which i will execute via shell_exec()
programmatically,
sudo echo "192.168.xx.xx example.com" >> /etc/hosts
but this is not working,it throws permission denied error.
So,can i edit host file dynamically using php or can i append a line into it?