Search code examples
phpcentos7gradlew

gradlew build successfully by ssh but faild by php exec ERROR "Please set the JAVA_HOME variable" in CENTOS 7


I set JAVA_HOME in .bash_profile and environment file. when run gradlew by terminal in centos build seccessfull, but when run same command by php exec get JAVA_HOME ERROR

$command = "$path/gradlew -c $path/settings.gradle assembleRelease";
exec($command, $output, $code);

ERROR: "Please set the JAVA_HOME variable in your environment to match the"


Solution

  • Fixed by send java_home in command string

    $javaHome = "JAVA_HOME=/opt/jdk1.8.0_161";
    $command = "$javaHome $path/gradlew -c $path/settings.gradle assembleRelease";
    exec($command, $output, $code);