Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am running uBuntu 12.04.3, 32 bit OS on a 8 CPU, 8GB RAM 64-bit Intel Xeon machine. I have installed all backports as well.

I have this problem which is eating my head for the last 3 days. I created a file with the following code...


#! /bin/sh 

vlc -vvv sasural.ts

Where sasural.ts is a video file that resides under home and in the same level as Apache. I am invoking the .sh file by using the following PHP code...



I also tried both the exec() / system() methods to invoke the .sh file.

Whenever I do so, I get the following message...

VLC media player 2.2.0-git Weatherwax Command Line Interface initialized. Type `help' for help. > Shutting down. works if I execute it from the terminal command prompt outside of the PHP code. I guess I am doing something wrong when I invoke it from within PHP.

I have performed the following tasks...

  1. Given Apache Root Access
  2. Linked all folders to Apache
share|improve this question
What for is -vvv option? I use VLC media player 2.0.8 Twoflower and I have no problem. – Radu Rădeanu Aug 26 '13 at 15:10
Try hardcoding the path to the shell script - it's possible that while it's in the same directory as apache, it isn't in the same directory as where the PHP interpreter runs from – jackweirdy Aug 26 '13 at 15:34
@RaduRădeanu: I cannot use any VLC version under 2.1. My problem is that I have to get the media files from a server which only accepts https:// and any version under 2.1 does not allow manual acceptance / storage of certificates. Try navigating to and let me know if it shows on your VLC. – Seemant Mathur Aug 26 '13 at 17:35
No, it shows only strange characters. – Radu Rădeanu Aug 26 '13 at 17:47
Double checking - where are you expecting VLC to open? On the client or on the server? If you want it on the client, you won't be able to solve this with PHP – jackweirdy Aug 29 '13 at 18:26

Done it :)

That was fun :D

prerequisites: vlc must already be running fifo file must exist The below will set this up:

mkfifo /tmp/vlcfifo
chmod a+rw /tmp/vlcfifo
tail -f /tmp/vlcfifo | nohup vlc --intf rc &

in the php file:

passthru('echo "add /path/to/video.avi" | tee /tmp/vlcfifo');

Give that a try :)

share|improve this answer
I will try this out tomorrow morning! I hope this will work for the headless noX (Non GUI) version of VLC. – Seemant Mathur Aug 28 '13 at 21:10

In your script, before you launch vlc, have the line: export DISPLAY=:0

This should launch it in your primary X session, assuming the webserver is running on the same box as your X session.

You will also need to do something with sound if you require it. Like a remote ALSA or Pulseaudio server.

share|improve this answer
Assuming there is an X session on the system. This might be a server without a GUI. – Thomas Ward Aug 27 '13 at 20:32
Hey Thanks! i will try this out first thing tomorrow! I really - really hope this works! By the way this IS a headless (Non-GUI) server. Which also basically means that I have the noX version of VLC installed on it. Do you think this still could be the solutions? – Seemant Mathur Aug 28 '13 at 21:07
Using a headless server is fine, but you do need the basic X libs and the X version of VLC. The DISPLAY environment variable is telling you which X server to connect to. It's an easy way to display any X application on different X displays, and it doesn't have to be the same host either. I do this through SSH X11 forwarding all the time. I guess knowing more on what you are attempting to do would help, I just have picked up, "launching the GUI version of VLC through an Apache (I assume) PHP page." – Trevor Dell Aug 29 '13 at 17:48
up vote 1 down vote accepted


I have been able to solve this issue by using the following steps...

  • Install vlc nox version
  • In the PHP file: echo shell_exec("sh /var/www/");

  • In the file: #!/bin/sh vlc -Idummy /var/www/media.ts --sout '#standard{access=http,mux=ts,dst=:1935/}'

  • Invoke the PHP file via a browser and VLC will start streaming to port 1935

To access the file from the client end...

1) Point VLC or any media player to the URL + Port. Ex. 2) The client player will start to receive the file and play it back.

Now the next step is to enable this file on demand. Will post how I did that as well so stay tuned!!

Thank you everybody who have helped me in solving this problem. I have added +reps wherever it was possible.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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