Problem:
- I ran into an error trying to execute a system command in PHP 5.4.4 using exec, shell_exec, or system in MAMP.
- Example error: “image not found for libcaffe”.
- This command executed fine from Terminal, but would not work within MAMP.
-
<?php $cmd = "some command here"; shell_exec($cmd); ?>
Diagnosis:
- The $PATH did not seem to be correct (compared to what I have in ~/.bash_profile.), so MAMP must not be setting it up correctly
<?php shell_exec("echo $PATH"); ?>
Solution:
- Stop MAMP
- Copy unused environment variables file
cp /Applications/MAMP/Library/bin/envvars_ /Applications/MAMP/Library/bin/envvars
- Edit environment variables file
vi /Applications/MAMP/Library/bin/envvars
- Add the following line:
~/.bash_profile
- Start MAMP