Accessing FFMPEG installed above public_html webspace - php

On a shared server with ffmpeg installed above the webspace. Example: /home/username/ffmpeg/ffmpeg which is the full address all the way down to the executable.
The problem is that php cannot find ffmpeg using the -verson option. We tried using mod rewrite to a php file in the public_html webspace which then includes the ffmpeg address above the webspace. But that did not work.
I have never dealt with ffmpeg installed this way, its always been installed in /usr/bin/ or /usr/local/bin .
is there a htaccess or php ini command to tell php where ffmpeg is installed?
how does php suppose to access ffmpeg installed in this way, it is installed as an alias?
Thanks so much :)

As php and ffmpeg are separate things, there's no guarantee that your host will allow php to run ffmpeg, however here are some things you can try:
You can check if web server's user (which php runs as) can "see" any ffmpeg executables in its path by running:
<?php echo shell_exec("which ffmpeg"); ?>
If the output is empty, ffmpeg isn't in the path of the web server's user. In this case you still might be able to run it, if you know the path of the executable.
Also if you run:
<?php phpinfo(); ?>
That will tell you if php is running in safe mode. If it is, your web host may have locked down php's ability to do potentially dangerous things such as executing shell commands.

Change Permission of binaries files (ffmpeg.exe and ffprobe.exe) to 0744.
See image sample here:

Related

PHP run curl with exec not working

When I run my curl command in the command prompt it works fine, but
when I run it in my PHP file using exec it doesn't execute, can
somebody tell me why that is ? In the error log file it says,
"'curl' is not recognized as an internal or external command "
I checked my php configurations, curl is enabled there.
From what you write I guess you use windows so:
It can be executed from cmd.exe when you are exact directory where curl is installed but as other suggested if you want to have access to it globally you will need add curl.exe to your PATH variable.
Despite this, there is better way to use CURL in PHP than using exec. A whole module is available. You can go to this site and check it. To install php curl on windows you'll probably need to install an extension.
Notice from manual:
In order to enable this module on a Windows environment, libeay32.dll and ssleay32.dll must be present in your PATH. You don't need libcurl.dll from the cURL site.
Check this site as well.
Good luck
you probably do not have the path set. Set the environment path (add curl executable bin to the path) and then restart the command prompt. it should work
In your PHP script,
either use the full path to curl (which you can find out using which curl on the commandline),
or use the cURL API that is available in PHP. This is the preferred method because not all hosts have exec enabled for PHP.

PHP exec works on apache2 but not on nginx

I'm trying to launch unoconv using exec in php. It works with apache2, but not with nginx.
I've already checked my php.ini and disable_functions not contain exec in both apache2 and nginx php.ini files.
I'm not familiar with unconv, but I've had a similar problem with porting my server from Apache to nginx and exec.
nginx + php-fpm have a bare minimal $PATH set compared to apache, and it's likely your unoconv is not on that path.
You could try modifying your PATH settings, but a better way would be to specify the absolute path of unoconv
You can find the absolute path by using
which unoconv
You should also re-direct the error output to stdout, so you can see exactly why unoconv isn't starting
exec("/path/to/unoconv -param0 -param1 2>&1", $output);
print_r($output); //this should give failure reason
Check out this post : PHP exec() does not run all commands
As said in this post :
The problem is that you're running notify-send from a service. Notify-send is a desktop-oriented program which interacts with the display. But nginx runs without being attached to a display.
Imagine, for example, that there are 3 people logged on to the computer at the same time, all with different displays. When notify-send runs, it wouldn't know which display to send the notification to.

Append to the Apache Environment Path

I have a web accessible PHP script that is using a shell command to drop PDFs to text. I installed Poppler, and am using pdftotext, via MacPorts. I am able to run the command successfully from the CL, and when supplying the full path within the PHP script to '/opt/local/bin/pdftotext'. So, I know that my $PATH is correct and the permissions are sufficient, yet I am still getting an exit status of 127: Command Not Found, when attempting to do simply 'pdftotext' in the exec().
I have tried the answers from How do I add paths to the Apache PATH variable? and http://lists.apple.com/archives/macos-x-server/2008/Sep/msg00433.html. I modified both the /etc/paths and /etc/profile, and added /etc/paths.d/macports all pointing to '/opt/local/bin'. setenv, apache_setenv, etc all had no effect also.
I am using a MAMP (1.9 I think) install for my local development, OSX 10.6, PHP 5.3.5, all a little behind I know :-) ... my $PATH is modified to point to the MAMP bin/php
/etc/paths.d/macports will influence on PATH variable for macports, not for the Apache. You probably need to add /etc/parhs.d/apache (or else) to do what you need.
Edit: also check this and this threads for solutions. It is somewhat outdated but still can help.

save image when using php shell_exec and mac osx terminal command screen capture?

I was experimenting with shell_exec and commands, and I can't seem to get this work. Im using the php shell_exec() function and running a screen capture command to take a snapshot of the desktop. When running the script locally through coda, it works fine. Then i ran it through my installion of apache through htdocs, and it runs, yet it doesn't save the image anywhere? For browsers, do i need to change the directory at all? this is what my super simple script looks like. Is this even possible?
<?
$command = "screencapture -iWP ~/Random/test.png";
shell_exec($command);
?>
I don't currently have access to a Mac to test, but I'd be extremely surprised and more than a little concerned if that did work.
On the server, apache should be running under a different user ID to the logged in user, which means the attempt to grab the framebuffer should fail.
If it did at least write (or try to write) an image, then it will be ~/Random/test.png; e.g. if apache runs as a user called apache, the target filename is ~apache/Random/test.png
OSX is basically UNIX, and a key feature of UNIX-like operating systems is security. The video framebuffer should only be accessible to processes running under the UID of the logged in user (or root). Daemon processes like apache httpd should be running under their own, non-root UID.
You probably have to specify the full path of the executable. Also, specifying the full path of the output PNG would help too because they're different users.
Run the command
which screencapture
To find the path that the executable is located in. The output file must be in a writable directory for the user that apache is running under (usually apache). You can check the user that apache is running under by looking in the apache configuration, or just running "top" (as root).
Hope that helps.

Installed ffmpeg but i'm getting a "no such file or directory" error

I have installed ffmpeg and I can run it perfectly find when using the "ffmpeg" from the command line. But I am trying to run ffmpeg from PHP and when I use the bare ffmpeg command, I get "sh: ffmpeg: command not found". So instead of just the bare ffmpeg command, I used the whole folder location /home/vibe/public_html/libraries/ffmpeg/ffmpeg but now I get the "no such file or directory" error.
Anyone know how I can solve this? Much appreciated.
You have to adapt the configuration of your webserver... normally ffmpeg and stuff like that is installed in the same directory, for example /something/bin. So everytime you want to execute something in the shell, the OS will look into the /bin-folder. If ffmpeg is installed somewhere else (obviously it is in your case), you have to add the path to your path-variable, so the OS knows that it has to look there, too. Beside this, you should not install executables in your public_html folder!
I'd expect that your webserver doesn't have read permission for at least one of the files or directories in that path. The bad, shotgun solution for that would be:
chmod -R 777 /home/vibe/public_html
This would at least allow you to trivially verify that permissions are in fact your problem.

Categories