Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with php & nginx - "Unoconv failed to transcode file" #434

Closed
sentiasa opened this issue Jan 22, 2018 · 2 comments
Closed

Error with php & nginx - "Unoconv failed to transcode file" #434

sentiasa opened this issue Jan 22, 2018 · 2 comments

Comments

@sentiasa
Copy link

I have a been using a library called Unoconv. (Please note that in my local ubuntu [virtualbox-homestead], it's working as expected, but not in AWS.)

$unoconv = Unoconv::create([
    'unoconv.binaries' => '/usr/bin/unoconv',
]);

This is what I call in php. And I can confirm that /usr/bin/unoconv exists.

The initial error was:

exception: "Unoconv\Exception\RuntimeException"
file : "/usr/bin/unoconv"


First, I though it was permission issue. So I adapted accordingly:

My Homestead permissions: -rwxr-xr-x 1 root root 63243 Aug 18 2015 unoconv

My AWS permissions: -rwxr-xr-x 1 root root 63243 Aug 18 2015 unoconv

Then I changed my AWS group to:

-rwxr-xr-x 1 www-data www-data 63243 Aug 18 2015 /usr/bin/unoconv


Then I tried editing /etc/nginx/fastcgi_params and added this line:

// This existed, so I didn't touch it
fastcgi_param REDIRECT_STATUS 200;

// I added this line
fastcgi_param PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/opt/node/bin

[In fact, I ended up thinking above thing is totally wrong]

And my nginx looks like this:

    location ~ \.php$ {
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
    }

The error has now changed to:

exception: "Unoconv\Exception\RuntimeException"
file: "/var/www/my_proj/vendor/php-unoconv/php-unoconv/src/Unoconv/Unoconv.php"
line: 68
message:"Unoconv failed to transcode file"

The file path is changed.


Finally, I tried removing fastcgi_param REDIRECT_STATUS 200;, but nginx doesn't compile/throws a syntax error.

I am stuck on how to overcome the issue.


Update:

In /etc/init.d/php7.0-fpm, I can see PATH=/sbin:/usr/sbin:/bin:/usr/bin, but I am not sure how to fix this issue. Should I use /bin instead of /usr/bin? If I do, I get an error "Executable not found, proposed : /bin/unoconv"

Or is it permission issue?

How can I debug successfully? I'd appreciate any help! Thanks in advance

@bertalanimre
Copy link

For me, the solution was this:
sudo vim /etc/php-fpm.d/mywebsite.conf

Find the line: env[PATH] = /usr/local/bin:/usr/bin:/bin and uncomment it.

Then restart php-fpm and it should be working. You might also need a service file as well with something very similar content:

[Unit]
Description=Unoconv listener for document conversions
Documentation=https://github.com/dagwieers/unoconv
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=simple
Environment="UNO_PATH=/usr/lib64/libreoffice/program"
ExecStart=/usr/bin/unoconv --listener

[Install]
WantedBy=multi-user.target

The think you might need to modify is the UNO_PATH which is the path for your libreoffice installation. Hope I've helped. (I'm on CentOS, unable to tell you exactly the file routes)

@regebro
Copy link
Member

regebro commented Feb 18, 2019

It seems to me that the error codes here are all PHP error codes, and what you need to debug this is to get the actual output of Unoconv and see what error it raises.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants