Php – Cannot write log file ‘ffmpeg2pass-0.log’ for pass-1 encoding: Permission denied

apache-2.2ffmpegPHPselinux

Our PHP application is installed as 'root' on a Redhat5/CentOS system at: /var/www/html/beta/

After disabling SELINUX in order to allow these scripts to execute other programs on the system – What permissions are needed to run a system() command within a php script that writes to a folder?

I faced the error that the Apache error_log showed this:

 Cannot write log file 'ffmpeg2pass-0.log' for pass-1 encoding: Permission denied

Best Answer

The problem was that I had run ffmpeg as root at the same location, which created the 'ffmpeg2pass-0.log' log file.

I had changed permission on /var/www/html/beta to:

- drwxrwxr-x 19 apache apache 12288 Oct 25 08:20 beta

so that apache had appropriate permissions to write to the folder.

However, since I already had the log file at the same location (which had been created as 'root'), user 'apache' was unable to write/append to it! Hence the error message that I saw.

I simply deleted all instances of this file and that worked perfectly!