How to add a package to trellis that can be used by another PHP/WordPress package?

Hi there,

A WordPress plugin I’m using is asking for ffmpeg to be installed on the server.

I’ve gone into trellis/roles/common/defaults and added the following:

apt_packages_custom:
  ffmpeg: "{{ apt_package_state }}"

This works well, except that the binary can’t be used by PHP because of open_basedir.

I get the following:

Warning: file_exists(): open_basedir restriction in effect. File(/usr/bin/ffprobe) is not within the allowed path(s): (/srv/www/:/tmp) …

It looks like open_basedir is configured to allow the web root and the /tmp directory.

Ways I can think of are:

  • create a symbolic link from copy/move the binaries to /tmp or the web root
  • install the package as the web user somehow, to a different path somehow (like /usr/local/bin or some such)
  • edit open_basedir to include the binaries’ current path (insecure?)
  • after install, copy/move/symlink the files to be inside the www/shared directory

Is there an established way for binaries to be accessed by PHP at run time that I should follow? I can’t see one yet; the closest is wp-cli but that’s still designed to be run as the user and not the PHP process, which means open_basedir doesn’t apply.

Any help much appreciated!

EDIT: Symlinks aren’t working so for now I have manually copied them into /srv/www/bin

1 Like

Yeah this would work, but in this case it would allow anything in /usr/bin which isn’t ideal.

What you did sounds good to me :+1: