Home » Php » php – Libreoffice source not found aws linux

php – Libreoffice source not found aws linux

Posted by: admin July 12, 2020 Leave a comment


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 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;
    $result = false;
    if (file_exists($outfile)) {
        $result = rename($outfile, $this->destination);

    // remove temporary sub directory
    return $result;

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

How to&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


You have to change the ownership of your directory where your storing the files, Please try the below command on your aws ubuntu machine.

sudo chown -R www-data:www-data /var/www/my-project/


This issue has only 2 scenarios

  1. The user dont have permission.
  2. The problem is from the code.

I’m moving on the assumption that Laravel is working well with you except for this part

This means that you have access to the storage files, why don’t you save there?

If you can save there, compare the folders and your problem is solved.

If you cannot save there, then the issue is from the code which I doubt as you stated that everything is working well previously.