Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Libreoffice source not found aws linux

I am trying to convert a files from doc to pdf on my aws linux server. On my previous machine it worked fine but now i am having issues on my new machine. The only difference is i have upgraded from PHP 7.0 to PHP 7.2. and libre office version

LibreOffice 6.0.1.1 00m0(Build:1)

I have tried giving root permissions to libreoffice and the package that executes the command but no success.

This is the package i am using https://github.com/szonov/libreoffice-converter

I am using it with laravel 5.4. This is the code in the package that performs the action

    $replacement = array(
        'bin'        => $this->bin,
        'convert_to' => $convert_to,
        'outdir'     => $outdir,
        'source'     => $this->source
    );
    $cmd = $this->makeCommand($replacement);
    $cmd = "sudo ".$cmd;
    shell_exec($cmd);
    $result = false;
    if (file_exists($outfile)) {
        $this->mkdir(dirname($this->destination));
        $result = rename($outfile, $this->destination);
    }

    // remove temporary sub directory
    rmdir($outdir);
    return $result;

I have tried appending sudo since when i dd the command and execute is using sudo it worked in command line..

like image 539
Syed Abdur Rehman Kazmi Avatar asked Feb 25 '18 14:02

Syed Abdur Rehman Kazmi


1 Answers

So you need to either use something like below

Execute root commands via PHP

Or you should enable to login to the www-data user

sudo usermod -s /bin/bash www-data

Then you should login with that user and fix all the issues with permissions so you can run the command

sudo su www-data

Once you have done this make sure to reset the login using below

sudo usermod -s /bin/nologin www-data

Once the issue is sorted out in user terminal, you can run the commands without issue in apache as well

like image 86
Tarun Lalwani Avatar answered Sep 19 '22 08:09

Tarun Lalwani