I'm trying to compile C++ programs through PHP's exec() function. The command works when running directly from the command line and the program compiles perfectly, but in PHP exec() the error g++: error trying to exec 'cc1plus': execvp: No such file or directory surfaces.
I am running PHP-FPM 7.1 with the user www-data.
In PHP the command in question is exec('g++ /home/username/example.cpp -o main.o 2>&1', $out);