I am working on project using symfony 3, the project run on nginx server and i am trying to reload the configuration files with the following command: "systemctl reload nginx" from the controller.
/**
* @Route("/testReloadConfig")
*/
public function testReloadConfigAction(Request $request){
$output = [];
$result = null;
$cmd = 'systemctl reload nginx 2>&1';
exec($cmd, $output, $result);
return new JsonResponse([
'result' => $result,
'output' => $output,
]);
}
The response:
{"result":1,"output":["Failed to reload nginx.service: Interactive authentication required.","See system logs and \u0027systemctl status nginx.service\u0027 for details."]}