I have set up a Laradock environment with Nginx and php-fpm containers running. From PHP I want to call an executable:
<?php
print exec('whoami'); // www-data
echo "<br>";
exec('/usr/local/bin/assimp version', $output, $returnValue);
print $returnValue; // 127
echo "<br>";
print_r($output); // Array ( )
?>
The return value 127 sounds to me as if the file is not found...
But when I enter the container with the user "www-data" everything works fine:
docker-compose exec --user www-data php-fpm bash
assimp version // -> valid info response
As I was unsure if the executable has to be placed in "workspace" or in the php-fpm container I tried both with the same result. Also putting the executable in the /var/www directory did not help.
The executable was added by the Dockerfile:
USER www-data
COPY ./assimp /usr/local/bin/assimp
COPY ./libassimp.so.4.1.0 /usr/local/lib/libassimp.so.4.1.0
RUN ln -s /usr/local/lib/libassimp.so.4.1.0 /usr/local/lib/libassimp.so
RUN chmod 777 /usr/local/bin/assimp
RUN echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bashrc
RUN echo 'export LD_LIBRARY_PATH=/usr/local/lib' >> ~/.bashrc
Any ideas how to fix this issue or how to continue with the debugging? Thanks in advance!
docker runpaths don’t actually read.bashrc, and putting things there in a Dockerfile isn’t a great practice. Just put things in directories that are already in the search/loader paths./usr/binand the lib to/usr/lib. The result is still the same. I found out that even if the lib is in a standard folder it is not found:ldconfig -p | grep libassimp.soin the php-fpm container delivers no result. Doing this in the workspace container works and the lib is found. Is it possible to tell php to execute a file from the workspace container and not from the php-fpm container?