0

I've compiled PHP from source on Debian Stretch in a docker container.

I have added this entry to my Supervisor config:

command=/bin/sh -c 'QUEUE=orders/create APP_INCLUDE=/var/www/html/jobs/OrdersCreate.php php /var/www/html/includes/vendor/resque/php-resque/resque.php >> /var/www/log/OrdersCreate.log 2>&1'
autostart=true
autorestart=true
priority=11
stdout_events_enabled=true
stderr_events_enabled=true
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0

It logs the error:

/bin/sh: 1: php: Permission denied.

If I add the full path to PHP /usr/bin/php/bin/php, it works fine.

Why is this and how can I make it work without specifying the full path?

Asa Carter
  • 249
  • 1
  • 3
  • 15

1 Answers1

1

You need to edit the $PATH environment variable to include the location which the php binary exists in.

In your Dockerfile:

ENV PATH "$PATH:/usr/bin/php/bin"
v25
  • 764
  • 1
  • 6
  • 14
  • I had previously done that with `export PATH=/usr/bin/php/bin:$PATH` that I found from another post. Was that incorrect? – Asa Carter Apr 16 '19 at 13:37
  • Both methods should work. Adding what I posted to the Dockerfile means this modification is part of the image. That could also be the case if you have a shell script (containing the `export` line) which runs while the container is built (Via a `RUN` command in the Dockerfile). I would avoid applying this at container runtime though (For example in an `ENTRYPOINT` script, as it should really be part of the image in my opinion. – v25 Apr 16 '19 at 13:47
  • I tested it before by adding it after the container was built. I'll rebuild it adding this line instead. – Asa Carter Apr 16 '19 at 13:51