I need to set multiple virtual host on Ubuntu 16.04,which can create manually.
But i want to do this with php dynamically.For this i have tried to create a file /tmp or in /www directory using a php's fopen function.So i can create a file but unable to move this file to /etc/apache2/sites-available directory using php shell_exec()
function.
To move temporarily created file i have used shell_exec(mv temp_file path_to_move);
but command not run via php code.Then i have tried to create file directly in /etc/apache2/sites-available
but it shows error Cannot open file
This is my code which i have used
<?php
$myfile = fopen("example.com.conf", "w");
$template ='<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>';
fwrite($myfile, $template );
fclose($myfile);
$cmd= 'mv'.$myfile.' /etc/apache2/sites-available';
shell_exec($cmd);
?>
It create file but move command not works