1

The same way as https://askubuntu.com/questions/364458/running-gui-app-with-php, I need to run a X11 application (VLC) from a php page on Apache server.

I need to open the VLC application on the server, not on the remote system.

I'm trying to get this through a php shell_exec call to a shell script containing the VLC commands.

The sh script correctly opens the VLC app if launched from command line, but not through the php call, because it does not find (I think) any X11 session initiated: it returns related error messages:

  - inhibit interface error: Failed to connect to the D-Bus session daemon: //bin/dbus-launch terminated abnormally with the following error: No protocol specified
  - Autolaunch error: X11 initialization failed.
  - main interface error: no suitable interface module
  - xcb_xv vout display error: parent window not available
  - ...

If I grant the apache user, www-data, to connect to the X server

xhost +local:www-data

it works for the video but not for audio; the windows opens and plays the video but without sound and still other error messages related to audio server...

export DISPLAY=:0 does not seem to have any effect.

Any help would be appreciated.

3

There's an X server running on the same computer as PHP? If that's the case you could* run the PHP process as the same user as the owner of the X server (by editing /etc/apache2/apache2.conf) and then chain in the display identifier onto the command:

shell_exec("DISPLAY=:0 vlc ....");

You can also use putenv (IIRC) to set the environment variables from PHP.

*But consider the security ramifications of doing this before you do. If something PHP was running was compromised (happens all the time), what damage could that do?

| improve this answer | |
  • Ok, this works...! But I'd really like to avoid the security hole it means, even if the "application" won't have any kind of public use at the moment. – Geojj Dec 16 '13 at 16:27
  • I think there is a way to export everything needed for a temporarily but "complete" X session for user www-data. Somthing like an equivalent php for linux of the solution found here (<stackoverflow.com/questions/2560497/…) for mac, osx... – Geojj Dec 16 '13 at 16:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.